Пример #1
0
    def __init__(self):

        self._init_vars()
        self.ui = None
        self.windowhome.setProperty("IconMixDataPath", ADDON_DATA_PATH)

        #get params
        action = None
        try:
            params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))

            if params:
                #logMsg("Appel Plugin : %s" %(params),0)
                path = params.get("path", None)
                if path: path = path[0]
                limit = params.get("limit", None)
                if limit: limit = int(limit[0])
                else: limit = 25
                action = params.get("action", None)
                if action: action = action[0].upper()

            if action:

                if action == "ICONMIXNEXTAIRED":
                    try:
                        windowhome = xbmcgui.Window(10000)
                    except:
                        windowhome = None
                    if windowhome:
                        cpt = 0
                        while cpt < 50:
                            if windowhome.getProperty(
                                    'MonNextAired.Actif') != 'oui':
                                Episodes = utils.GetNextEpisodesKodi()
                                if Episodes:
                                    xbmcplugin.addDirectoryItems(
                                        int(sys.argv[1]), Episodes)
                                xbmcplugin.endOfDirectory(int(sys.argv[1]))
                                cpt = 50
                            else:
                                xbmc.sleep(500)
                            cpt = cpt + 1
                if action == "ICONMIXMOVIEPROGRESS":
                    Liste = utils.GetProgress("movie")
                    if Liste:
                        xbmcplugin.addDirectoryItems(int(sys.argv[1]), Liste)
                    xbmcplugin.endOfDirectory(int(sys.argv[1]))

                if action == "ICONMIXTVPROGRESS":
                    Liste = utils.GetProgress("tvshow")
                    if Liste:
                        xbmcplugin.addDirectoryItems(int(sys.argv[1]), Liste)
                    xbmcplugin.endOfDirectory(int(sys.argv[1]))
                if action == "ICONMIXEPISODEPROGRESS":
                    Liste = utils.GetProgress("episode")
                    if Liste:
                        xbmcplugin.addDirectoryItems(int(sys.argv[1]), Liste)
                    xbmcplugin.endOfDirectory(int(sys.argv[1]))

                if action == "GETGENRELIST":
                    Id = params.get("id", None)
                    if Id: Id = Id[0]
                    genretype = params.get("genretype", None)
                    if genretype: genretype = genretype[0]
                    utils.getGenreListe(Id, genretype)

        except:
            params = {}

        try:
            params = dict(arg.split('=') for arg in sys.argv[1].split('&'))
        except:
            params = {}

        self.setview = params.get('setview', False)
        self.setviewmenu = params.get('setviewmenu', False)
        if self.setviewmenu:
            self.idview = params.get('id', None)

        self.videcache = params.get('videcache', False)
        self.addplaylist = params.get('addplaylist', False)
        self.supplaylist = params.get('supplaylist', False)
        self.updateallmusic = params.get('updateallmusic', False)
        self.mettreajour = params.get('mettreajour', False)
        if self.mettreajour:
            self.mettreajourID = params.get('id', False)
            self.mettreajourLABEL = params.get('label', False)
            self.mettreajourTYPE = params.get('type', False)
        self.backend = params.get('backend', False)
        self.updateacteursinf = params.get('updateacteursinf', False)
        if self.updateacteursinf:
            self.itemidkodi = params.get('idkodi', None)
            self.itemidtmdb = params.get('idtmb', None)
        self.togglewatchedepisode = params.get('togglewatchedepisode', None)
        self.itemidkodiepisode = params.get('idepisode', None)
        self.togglewatched = params.get('togglewatched', False)
        self.showinfo = params.get('showinfo', False)
        self.PurgeDatabase = params.get('purgedatabase', False)
        self.PurgeDatabaseManuel = params.get('purgedatabasemanuel', False)

        self.Positionnement = params.get('position', None)

        if self.Positionnement:

            self.ui = MainService.dialog_SelectPosition(
                'position.xml', ADDON_PATH, 'default', '1080i')
            ret = self.ui.doModal()
            del self.ui

        if self.togglewatchedepisode and self.itemidkodiepisode:
            self.windowhome.clearProperty('IconmixProchainEpisode')
            if self.togglewatched == "True":
                json_result = utils.setJSON(
                    'VideoLibrary.SetEpisodeDetails',
                    '{ "episodeid":%d,"resume":{"position":0,"total":0},"playcount":1 }'
                    % (int(self.itemidkodiepisode)))
            else:
                json_result = utils.setJSON(
                    'VideoLibrary.SetEpisodeDetails',
                    '{ "episodeid":%d,"resume":{"position":0,"total":0},"playcount":0 }'
                    % (int(self.itemidkodiepisode)))
            self.windowhome.setProperty('IconMixUpdateEpisodes', '1')

        #purge des series orphelines sans épisodes.....
        if self.PurgeDatabase and (SETTING("autopurge") == "true"
                                   or self.PurgeDatabaseManuel):

            try:
                from sqlite3 import dbapi2 as sqlite

            except:
                from pysqlite2 import dbapi2 as sqlite

            DB = os.path.join(xbmc.translatePath("special://database"),
                              'MyVideos107.db')
            db = sqlite.connect(DB)
            db.row_factory = lambda c, r: dict(
                [(col[0], r[idx]) for idx, col in enumerate(c.description)])
            rows = db.execute(
                'SELECT idShow,totalCount FROM tvshowcounts WHERE totalCount is NULL'
            )
            items = rows.fetchall()
            dialog = xbmcgui.Dialog()
            Choix = ["Toutes"]
            DelListe = [{"idShow": None, "idPath": None, "path": None}]
            for item in items:
                rows = db.execute(
                    'SELECT idShow,c00 FROM tvshow WHERE idShow="%s"' %
                    (item["idShow"]))
                TvShowItem = rows.fetchone()
                rows = db.execute(
                    'SELECT idShow,idPath FROM tvshowlinkpath WHERE idShow="%s"'
                    % (item["idShow"]))
                TvShowLinkPath = rows.fetchone()
                rows = db.execute(
                    'SELECT idPath,strPath FROM path WHERE idPath="%s"' %
                    (TvShowLinkPath["idPath"]))
                TvShowPath = rows.fetchone()

                Choix.append("%s=%s" %
                             (TvShowItem["c00"], TvShowPath["strPath"]))
                DelListe.append({
                    "idShow": item["idShow"],
                    "idPath": TvShowLinkPath["idPath"],
                    "path": TvShowPath["strPath"]
                })

            if len(Choix) > 1:
                if self.PurgeDatabaseManuel:
                    ret = dialog.multiselect("Series orphelines", Choix)
                else:
                    ret = [0]
                if ret and len(ret) > 0:
                    if ret[0] == 0:
                        for item in range(1, len(DelListe)):
                            db.execute(
                                'DELETE FROM tvshowlinkpath WHERE idShow = "%s"'
                                % (DelListe[item]["idShow"]))
                            db.execute('DELETE FROM path WHERE idPath = "%s"' %
                                       (DelListe[item]["idPath"]))
                            db.execute(
                                'DELETE FROM tvshow WHERE idShow = "%s"' %
                                (DelListe[item]["idShow"]))
                            db.commit()
                    else:
                        for item in ret:
                            db.execute(
                                'DELETE FROM tvshowlinkpath WHERE idShow = "%s"'
                                % (DelListe[item]["idShow"]))
                            db.execute('DELETE FROM path WHERE idPath = "%s"' %
                                       (DelListe[item]["idPath"]))
                            db.execute(
                                'DELETE FROM tvshow WHERE idShow = "%s"' %
                                (DelListe[item]["idShow"]))
                            db.commit()
                    #shutil.rmtree(DelListe[item]["path"])
                    xbmc.executebuiltin('Container.Refresh')
                    dialog.notification('IconMixTools', __language__(32860),
                                        ADDON_ICON, 500)
            else:
                if self.PurgeDatabaseManuel:
                    dialog.notification('IconMixTools', __language__(32861),
                                        ADDON_ICON, 500)

        if self.videcache:
            self.quelcache = params.get('cache', False)
            dialogC = xbmcgui.Dialog()
            ret = dialogC.yesno(
                "ICONMIXTOOLS CACHE !!!", __language__(32602), " ",
                str(self.quelcache).upper())  #-- Show a dialog 'YES/NO'.
            if ret > 0:
                utils.vidercache(self.quelcache)

        else:

            if not action:
                saga = ""
                #------ lancer mode serveur -----------
                if self.backend:
                    return
                # and xbmc.getCondVisibility("String.IsEmpty(Window(home).Property(IconMixToolsbackend))"):
                #    MainService.MainService()

                #-------------METTRE A JOUR SAGA ou SERIE-------------
                if self.mettreajour:
                    self.MiseAJour()

                #-------------CHOIX DE LA VUE-------------
                if self.setview:
                    self.SelectionneVue()

                if self.setviewmenu and self.idview:
                    xbmc.executebuiltin("Container.SetViewMode(%s)" %
                                        self.idview)

                #{"jsonrpc":"2.0","method":"Playlist.Add","id":-2067158130,"params":{"playlistid":0,"item":{"directory":"special://profile/playlists/music/Long Tracks.xsp"}}}
                #{"jsonrpc":"2.0","method":"Player.Open","id":1877953368,"params":{"options":{"shuffled":true},"item":{"playlistid":0,"position":0}}}
                #-------------AJOUTER A UNE PLAYLIST-------------
                if self.addplaylist:
                    utils.AddToPlayList()
                #-------------SUPPRIMER D'UNE PLAYLIST-------------
                if self.supplaylist:
                    utils.DelFromPlayList()

                if self.updateacteursinf and self.windowhome.getProperty(
                        'IconmixShowInfo') == "1":
                    ListeActeurs = self.GetControl(self.windowvideoinf, 1998)
                    #ACTEURS  ------------------------------------------------
                    if ListeActeurs:
                        ListeItemx = utils.getCasting("movie", self.itemidkodi,
                                                      1, self.itemidtmdb)
                        ListeActeurs.reset()
                        if ListeItemx:
                            #logMsg("Acteursinf.....")
                            for itemX in ListeItemx:
                                ListeActeurs.addItem(itemX)

                        status = ""
Пример #2
0
    def __init__(self):

        self._init_vars()
        self.ui = None
        self.windowhome.setProperty("IconMixDataPath", ADDON_DATA_PATH)

        #get params
        action = None
        try:
            params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))

            if params:
                #logMsg("Plugin : %s" %(params),0)
                path = params.get("path", None)
                if path: path = path[0]
                limit = params.get("limit", None)
                if limit: limit = int(limit[0])
                else: limit = 25
                action = params.get("action", None)
                if action: action = action[0].upper()

            if action:
                if action == "GETGENRE":
                    genre = params.get("genre", None)
                    if genre: genre = genre[0]

                    genretype = params.get("genretype", None)
                    if genretype: genretype = genretype[0]
                    origtitle = params.get("title", None)
                    if origtitle: origtitle = origtitle[0]
                    #if origtitle and genre and genretype:
                    utils.getGenre(genre, genretype, origtitle)

                if action == "GETCAST":
                    Id = params.get("id", None)
                    if Id: Id = Id[0]
                    castingtype = params.get("casttype", None)
                    if castingtype: castingtype = castingtype[0]
                    utils.getCasting(castingtype, Id)

                if action == "GETEPISODESKODI":
                    Id = params.get("id", None)
                    if Id: Id = Id[0]
                    Episodes = utils.GetEpisodesKodi(Id, False)
                    if Episodes:
                        xbmcplugin.addDirectoryItems(int(sys.argv[1]),
                                                     Episodes)
                    xbmcplugin.endOfDirectory(int(sys.argv[1]))
                    OldTvShowId = self.windowhome.getProperty(
                        'IconmixFlagPanelEpisode')
                    if OldTvShowId != Id:
                        self.windowhome.clearProperty(
                            'IconmixFlagPanelEpisode')

                if action == "GETARTISTEART":
                    Id = params.get("id", None)
                    if Id: Id = Id[0]
                    castingtype = params.get("casttype", None)
                    if castingtype: castingtype = castingtype[0]
                    Id = xbmc.getInfoLabel("ListItem.DBID")
                    utils.getArtisteArt(castingtype, Id)

                if action == "GETMENUVIEW":
                    if (len(sys.argv) > 1 and sys.argv[1]):
                        content_type = utils.VueActuelle()
                        if not content_type:
                            content_type = "files"
                        current_view = xbmc.getInfoLabel(
                            "Container.Viewmode").decode("utf-8")

                        ListeVues = utils.ModeVuesMenu(content_type,
                                                       current_view)
                        if ListeVues:
                            #logMsg("ListeVues ok (%s)" %(ListeVues))
                            xbmcplugin.addDirectoryItems(
                                int(sys.argv[1]), ListeVues)
                        xbmcplugin.endOfDirectory(int(sys.argv[1]))
        except:
            params = {}

        try:
            params = dict(arg.split('=') for arg in sys.argv[1].split('&'))
        except:
            params = {}

        self.trailer = params.get('trailer', False)
        self.trailerTypeVideo = params.get('dbtype', None)
        self.trailerTitre = params.get('label', None)
        self.trailerAnnee = params.get('year', None)
        self.trailerKODIID = params.get('dbid', None)
        self.trailerIMDBID = params.get('imdbnumber', None)
        self.trailerTMDBID = params.get('tmdbnumber', None)

        self.setview = params.get('setview', False)
        self.setviewmenu = params.get('setviewmenu', False)
        if self.setviewmenu:
            self.idview = params.get('id', None)
            #logMsg("On y est !!! (%s)(%s)" %(self.idview,params))

        self.videcache = params.get('videcache', False)
        self.addplaylist = params.get('addplaylist', False)
        self.supplaylist = params.get('supplaylist', False)
        self.updateallmusic = params.get('updateallmusic', False)
        self.mettreajour = params.get('mettreajour', False)
        self.backend = params.get('backend', False)
        self.updateacteursinf = params.get('updateacteursinf', False)
        if self.updateacteursinf:
            self.itemidkodi = params.get('idkodi', None)
            self.itemidtmdb = params.get('idtmb', None)
        self.showinfo = params.get('showinfo', False)

        if self.videcache:
            self.quelcache = params.get('cache', False)
            dialogC = xbmcgui.Dialog()
            ret = dialogC.yesno(
                "ICONMIXTOOLS CACHE !!!", __language__(32602), " ",
                str(self.quelcache).upper())  #-- Show a dialog 'YES/NO'.
            if ret > 0:
                utils.vidercache(self.quelcache)

        else:

            if not action:
                saga = ""
                #------ lancer mode serveur -----------
                if self.backend and xbmc.getCondVisibility(
                        "String.IsEmpty(Window(home).Property(IconMixToolsbackend))"
                ):
                    MainService.MainService()

                #-------------METTRE A JOUR SAGA ou SERIE-------------
                if self.mettreajour:
                    self.MiseAJour()

                #-------------BANDES ANNONCES-------------
                if self.trailer:
                    self.GetTrailer()

                #-------------CHOIX DE LA VUE-------------
                if self.setview:
                    self.SelectionneVue()

                if self.setviewmenu and self.idview:
                    xbmc.executebuiltin("Container.SetViewMode(%s)" %
                                        self.idview)

            #     self.SelectionneVueMenu()

#{"jsonrpc":"2.0","method":"Playlist.Add","id":-2067158130,"params":{"playlistid":0,"item":{"directory":"special://profile/playlists/music/Long Tracks.xsp"}}}
#{"jsonrpc":"2.0","method":"Player.Open","id":1877953368,"params":{"options":{"shuffled":true},"item":{"playlistid":0,"position":0}}}
#-------------AJOUTER A UNE PLAYLIST-------------
                if self.addplaylist:
                    utils.AddToPlayList()
                #-------------SUPPRIMER D'UNE PLAYLIST-------------
                if self.supplaylist:
                    utils.DelFromPlayList()

                if self.updateacteursinf and self.windowhome.getProperty(
                        'IconmixShowInfo') == "1":
                    ListeActeurs = self.GetControl(self.windowvideoinf, 1998)
                    #ACTEURS  ------------------------------------------------
                    if ListeActeurs:
                        ListeItemx = utils.getCasting("movie", self.itemidkodi,
                                                      1, self.itemidtmdb)
                        ListeActeurs.reset()
                        if ListeItemx:
                            #logMsg("Acteursinf.....")
                            for itemX in ListeItemx:
                                ListeActeurs.addItem(itemX)

                        status = ""