def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        path = sys.argv[2]
        params = urlparse.parse_qs(path[1:])
        log.warn("Parameter string: %s", path)
        try:
            mode = params['mode'][0]
        except (IndexError, KeyError):
            mode = ""

        if "/extrafanart" in base_url:

            emby_path = path[1:]
            emby_id = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(emby_id, emby_path)

        elif "/Extras" in base_url or "/VideoFiles" in base_url:

            emby_path = path[1:]
            emby_id = params.get('id', [""])[0]
            entrypoint.getVideoFiles(emby_id, emby_path)

        elif not self._modes(mode, params):
            # Other functions
            if mode == 'settings':
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')

            elif mode in ('manualsync', 'fastsync', 'repair'):
                self._library_sync(mode)

            elif mode == 'texturecache':
                import artwork
                artwork.Artwork().texture_cache_sync()
            else:
                entrypoint.doMainListing()
Exemple #2
0
    def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        path = sys.argv[2]
        params = urlparse.parse_qs(path[1:])
        log.warn("Parameter string: %s", path)
        try:
            mode = params['mode'][0]
        except (IndexError, KeyError):
            mode = ""

        if "/extrafanart" in base_url:

            emby_path = path[1:]
            emby_id = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(emby_id, emby_path)

        elif "/Extras" in base_url or "/VideoFiles" in base_url:

            emby_path = path[1:]
            emby_id = params.get('id', [""])[0]
            entrypoint.getVideoFiles(emby_id, emby_path)

        elif not self._modes(mode, params):
            # Other functions
            if mode == 'settings':
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')

            elif mode in ('manualsync', 'fastsync', 'repair'):
                self._library_sync(mode)

            elif mode == 'texturecache':
                import artwork
                artwork.Artwork().texture_cache_sync()
            else:
                entrypoint.doMainListing()
Exemple #3
0
    def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        log("Parameter string: %s" % sys.argv[2], 0)
        try:
            mode = params['mode'][0]
            itemid = params.get('id')
            if itemid:
                itemid = itemid[0]
        except:
            params = {}
            mode = ""

        modes = {
            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'adduser': entrypoint.addUser,
            'thememedia': entrypoint.getThemeMedia,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'deviceid': entrypoint.resetDeviceId,
            'delete': entrypoint.deleteItem
        }

        if "/extrafanart" in sys.argv[0]:
            embypath = sys.argv[2][1:]
            embyid = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(embyid, embypath)
            return

        if "/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]:
            embypath = sys.argv[2][1:]
            embyid = params.get('id', [""])[0]
            entrypoint.getVideoFiles(embyid, embypath)
            return

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)

            elif mode in ("channels", "getsubfolders"):
                modes[mode](itemid)

            elif mode == "browsecontent":
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('folderid', [""])[0])

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)

            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')

            elif mode in ("manualsync", "fastsync", "repair"):

                if window('emby_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(heading=lang(29999), line1=lang(33034))
                    log("Not connected to the emby server.", 1)
                    return

                if window('emby_dbScan') != "true":
                    import librarysync
                    lib = librarysync.LibrarySync()
                    if mode == "manualsync":
                        librarysync.ManualSync().sync(dialog=True)
                    elif mode == "fastsync":
                        lib.startSync()
                    else:
                        lib.fullSync(repair=True)
                else:
                    log("Database scan is already running.", 1)

            elif mode == "texturecache":
                import artwork
                artwork.Artwork().fullTextureCacheSync()

            else:
                entrypoint.doMainListing()
Exemple #4
0
    def __init__(self):
        # Parse parameters
        xbmc.log("PlexKodiConnect - Full sys.argv received: %s" % sys.argv)
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        xbmc.log("PlexKodiConnect - Parameter string: %s" % sys.argv[2])
        try:
            mode = params['mode'][0]
            itemid = params.get('id', '')
            if itemid:
                try:
                    itemid = itemid[0]
                except:
                    pass
        except:
            params = {}
            mode = ""

        modes = {

            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'adduser': entrypoint.addUser,
            'thememedia': entrypoint.getThemeMedia,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'companion': entrypoint.plexCompanion,
            'switchuser': entrypoint.switchPlexUser,
            'deviceid': entrypoint.resetDeviceId,
            'reConnect': entrypoint.reConnect,
            'delete': entrypoint.deleteItem,
            'browseplex': entrypoint.BrowsePlexContent,
            'ondeck': entrypoint.getOnDeck,
            'chooseServer': entrypoint.chooseServer,
            'watchlater': entrypoint.watchlater
        }

        if "/extrafanart" in sys.argv[0]:
            embypath = sys.argv[2][1:]
            embyid = params.get('id',[""])[0]
            entrypoint.getExtraFanArt(embyid,embypath)

        # Called by e.g. 3rd party plugin video extras
        if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0] or
                "/Extras" in sys.argv[2]):
            plexId = params.get('id', [None])[0]
            entrypoint.getVideoFiles(plexId, params)

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                # modes[mode](itemid, dbid)
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)
            
            elif mode in ["channels","getsubfolders"]:
                modes[mode](itemid)
                
            elif mode == "browsecontent":
                modes[mode]( itemid, params.get('type',[""])[0], params.get('folderid',[""])[0] )

            elif mode == 'browseplex':
                modes[mode](
                    itemid,
                    params.get('type', [""])[0],
                    params.get('folderid', [""])[0])

            elif mode in ('ondeck', 'recentepisodes'):
                modes[mode](
                    itemid,
                    params.get('type', [""])[0],
                    params.get('tagname', [""])[0],
                    int(params.get('limit', [""])[0]))

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            elif mode == "companion":
                modes[mode](itemid, params=sys.argv[2])
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
            elif mode in ("manualsync", "repair"):
                if utils.window('emby_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(heading="PlexKodiConnect",
                                        line1=("Unable to run the sync, the add-on is not "
                                               "connected to the Emby server."))
                    utils.logMsg("PLEX", "Not connected to the emby server.", 1)
                    return
                    
                else:
                    if mode == 'repair':
                        utils.window('plex_runLibScan', value="repair")
                        utils.logMsg("PLEX", "Requesting repair lib sync", 1)
                    elif mode == 'manualsync':
                        utils.logMsg("PLEX", "Requesting full library scan", 1)
                        utils.window('plex_runLibScan', value="full")
                    
            elif mode == "texturecache":
                import artwork
                artwork.Artwork().FullTextureCacheSync()
            else:
                entrypoint.doMainListing()
Exemple #5
0
    def __init__(self):
        # Parse parameters
        xbmc.log("PlexKodiConnect - Full sys.argv received: %s" % sys.argv)
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        xbmc.log("PlexKodiConnect - Parameter string: %s" % sys.argv[2])
        try:
            mode = params['mode'][0]
            itemid = params.get('id', '')
            if itemid:
                try:
                    itemid = itemid[0]
                except:
                    pass
        except:
            params = {}
            mode = ""

        modes = {
            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'adduser': entrypoint.addUser,
            'thememedia': entrypoint.getThemeMedia,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'companion': entrypoint.plexCompanion,
            'switchuser': entrypoint.switchPlexUser,
            'deviceid': entrypoint.resetDeviceId,
            'reConnect': entrypoint.reConnect,
            'delete': entrypoint.deleteItem,
            'browseplex': entrypoint.BrowsePlexContent,
            'ondeck': entrypoint.getOnDeck,
            'chooseServer': entrypoint.chooseServer,
            'watchlater': entrypoint.watchlater
        }

        if "/extrafanart" in sys.argv[0]:
            embypath = sys.argv[2][1:]
            embyid = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(embyid, embypath)

        # Called by e.g. 3rd party plugin video extras
        if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]
                or "/Extras" in sys.argv[2]):
            plexId = params.get('id', [None])[0]
            entrypoint.getVideoFiles(plexId, params)

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                # modes[mode](itemid, dbid)
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)

            elif mode in ["channels", "getsubfolders"]:
                modes[mode](itemid)

            elif mode == "browsecontent":
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('folderid', [""])[0])

            elif mode == 'browseplex':
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('folderid', [""])[0])

            elif mode in ('ondeck', 'recentepisodes'):
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('tagname', [""])[0],
                            int(params.get('limit', [""])[0]))

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            elif mode == "companion":
                modes[mode](itemid, params=sys.argv[2])
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin(
                    'Addon.OpenSettings(plugin.video.plexkodiconnect)')
            elif mode in ("manualsync", "repair"):
                if utils.window('emby_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(
                        heading="PlexKodiConnect",
                        line1=("Unable to run the sync, the add-on is not "
                               "connected to the Emby server."))
                    utils.logMsg("PLEX", "Not connected to the emby server.",
                                 1)
                    return

                else:
                    if mode == 'repair':
                        utils.window('plex_runLibScan', value="repair")
                        utils.logMsg("PLEX", "Requesting repair lib sync", 1)
                    elif mode == 'manualsync':
                        utils.logMsg("PLEX", "Requesting full library scan", 1)
                        utils.window('plex_runLibScan', value="full")

            elif mode == "texturecache":
                import artwork
                artwork.Artwork().FullTextureCacheSync()
            else:
                entrypoint.doMainListing()
    def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        xbmc.log("Parameter string: %s" % sys.argv[2])
        try:
            mode = params["mode"][0]
            itemid = params.get("id")
            if itemid:
                itemid = itemid[0]
        except:
            params = {}
            mode = ""

        modes = {
            "reset": utils.reset,
            "resetauth": entrypoint.resetAuth,
            "extrafanart": entrypoint.getExtraFanArt,
            "play": entrypoint.doPlayback,
            "passwords": utils.passwordsXML,
            "adduser": entrypoint.addUser,
            "thememedia": entrypoint.getThemeMedia,
            "channels": entrypoint.BrowseChannels,
            "channelsfolder": entrypoint.BrowseChannels,
            "browsecontent": entrypoint.BrowseContent,
            "getsubfolders": entrypoint.GetSubFolders,
            "nextup": entrypoint.getNextUpEpisodes,
            "inprogressepisodes": entrypoint.getInProgressEpisodes,
            "recentepisodes": entrypoint.getRecentEpisodes,
            "refreshplaylist": entrypoint.refreshPlaylist,
        }

        if "extrafanart" in sys.argv[0]:
            entrypoint.getExtraFanArt()

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get("dbid")
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
                limit = int(params["limit"][0])
                modes[mode](itemid, limit)

            elif mode in ["channels", "getsubfolders"]:
                modes[mode](itemid)

            elif mode == "browsecontent":
                modes[mode](itemid, params.get("type", [""])[0], params.get("folderid", [""])[0])

            elif mode == "channelsfolder":
                folderid = params["folderid"][0]
                modes[mode](itemid, folderid)

            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin("Addon.OpenSettings(plugin.video.emby)")
            elif mode in ("manualsync", "repair"):
                if utils.window("emby_dbScan") != "true":
                    import librarysync

                    lib = librarysync.LibrarySync()
                    if mode == "manualsync":
                        librarysync.ManualSync()
                    else:
                        lib.fullSync(repair=True)
                else:
                    utils.logMsg("EMBY", "Database scan is already running.", 1)

            elif mode == "texturecache":
                import artwork

                artwork.Artwork().FullTextureCacheSync()
            else:
                entrypoint.doMainListing()
Exemple #7
0
    def __init__(self):
        log.debug('Full sys.argv received: %s' % argv)
        # Parse parameters
        params = dict(parse_qsl(argv[2][1:]))
        mode = params.get('mode', '')
        itemid = params.get('id', '')

        if mode == 'play':
            self.play()

        elif mode == 'plex_node':
            self.play()

        elif mode == 'ondeck':
            entrypoint.getOnDeck(itemid,
                                 params.get('type'),
                                 params.get('tagname'),
                                 int(params.get('limit')))

        elif mode == 'recentepisodes':
            entrypoint.getRecentEpisodes(itemid,
                                         params.get('type'),
                                         params.get('tagname'),
                                         int(params.get('limit')))

        elif mode == 'nextup':
            entrypoint.getNextUpEpisodes(params['tagname'],
                                         int(params['limit']))

        elif mode == 'inprogressepisodes':
            entrypoint.getInProgressEpisodes(params['tagname'],
                                             int(params['limit']))

        elif mode == 'browseplex':
            entrypoint.browse_plex(key=params.get('key'),
                                   plex_section_id=params.get('id'))

        elif mode == 'getsubfolders':
            entrypoint.GetSubFolders(itemid)

        elif mode == 'watchlater':
            entrypoint.watchlater()

        elif mode == 'channels':
            entrypoint.channels()

        elif mode == 'settings':
            executebuiltin('Addon.OpenSettings(%s)' % v.ADDON_ID)

        elif mode == 'enterPMS':
            entrypoint.enterPMS()

        elif mode == 'reset':
            reset()

        elif mode == 'togglePlexTV':
            entrypoint.togglePlexTV()

        elif mode == 'resetauth':
            entrypoint.resetAuth()

        elif mode == 'passwords':
            passwordsXML()

        elif mode == 'switchuser':
            entrypoint.switchPlexUser()

        elif mode in ('manualsync', 'repair'):
            if window('plex_online') != 'true':
                # Server is not online, do not run the sync
                dialog('ok', lang(29999), lang(39205))
                log.error('Not connected to a PMS.')
            else:
                if mode == 'repair':
                    window('plex_runLibScan', value='repair')
                    log.info('Requesting repair lib sync')
                elif mode == 'manualsync':
                    log.info('Requesting full library scan')
                    window('plex_runLibScan', value='full')

        elif mode == 'texturecache':
            window('plex_runLibScan', value='del_textures')

        elif mode == 'chooseServer':
            entrypoint.chooseServer()

        elif mode == 'refreshplaylist':
            log.info('Requesting playlist/nodes refresh')
            window('plex_runLibScan', value='views')

        elif mode == 'deviceid':
            self.deviceid()

        elif mode == 'fanart':
            log.info('User requested fanarttv refresh')
            window('plex_runLibScan', value='fanart')

        elif '/extrafanart' in argv[0]:
            plexpath = argv[2][1:]
            plexid = itemid
            entrypoint.getExtraFanArt(plexid, plexpath)
            entrypoint.getVideoFiles(plexid, plexpath)

        # Called by e.g. 3rd party plugin video extras
        elif ('/Extras' in argv[0] or '/VideoFiles' in argv[0] or
                '/Extras' in argv[2]):
            plexId = itemid or None
            entrypoint.getVideoFiles(plexId, params)

        else:
            entrypoint.doMainListing(content_type=params.get('content_type'))
    def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        addon_handle = int(sys.argv[1])
        params = urlparse.parse_qs(sys.argv[2][1:])
        xbmc.log("Parameter string: %s" % sys.argv[2])

        try:
            mode = params['mode'][0]
            itemid = params.get('id')
            if itemid:
                itemid = itemid[0]
        except:
            params = {}
            mode = ""


        modes = {

            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'adduser': entrypoint.addUser,
            'thememedia': entrypoint.getThemeMedia,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes
        }

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)
            
            elif mode == "channels":
                modes[mode](itemid)

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
            elif mode in ("manualsync", "repair"):
                import librarysync
                if mode == "manualsync":
                    librarysync.LibrarySync().fullSync(manualrun=True)
                else:
                    librarysync.LibrarySync().fullSync(repair=True)
            elif mode == "texturecache":
                import artwork
                artwork.Artwork().FullTextureCacheSync()
            elif "extrafanart" in sys.argv[0]:
                entrypoint.getExtraFanArt()
            else:
                entrypoint.doMainListing()
    def __init__(self):

        # Parse parameters
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        xbmc.log("Parameter string: %s" % sys.argv[2])
        try:
            mode = params['mode'][0]
            itemid = params.get('id')
            if itemid:
                itemid = itemid[0]
        except:
            params = {}
            mode = ""


        modes = {

            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'extrafanart': entrypoint.getExtraFanArt,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'adduser': entrypoint.addUser,
            'thememedia': entrypoint.getThemeMedia,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist
        }
        
        if "extrafanart" in sys.argv[0]:
            entrypoint.getExtraFanArt()

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)
            
            elif mode in ["channels","getsubfolders"]:
                modes[mode](itemid)
                
            elif mode == "browsecontent":
                modes[mode]( itemid, params.get('type',[""])[0], params.get('folderid',[""])[0] )

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
            elif mode in ("manualsync", "repair"):
                if utils.window('emby_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(heading="Emby for Kodi",
                                        line1=("Unable to run the sync, the add-on is not "
                                               "connected to the Emby server."))
                    utils.logMsg("EMBY", "Not connected to the emby server.", 1)
                    return
                    
                if utils.window('emby_dbScan') != "true":
                    import librarysync
                    lib = librarysync.LibrarySync()
                    if mode == "manualsync":
                        librarysync.ManualSync()
                    else:
                        lib.fullSync(repair=True)
                else:
                    utils.logMsg("EMBY", "Database scan is already running.", 1)
                    
            elif mode == "texturecache":
                import artwork
                artwork.Artwork().FullTextureCacheSync()
            else:
                entrypoint.doMainListing()
    def __init__(self):
        # Parse parameters
        log.warn("Full sys.argv received: %s" % sys.argv)
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        try:
            mode = params['mode'][0]
            itemid = params.get('id', '')
            if itemid:
                try:
                    itemid = itemid[0]
                except:
                    pass
        except:
            params = {}
            mode = ""

        modes = {
            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'companion': entrypoint.plexCompanion,
            'switchuser': entrypoint.switchPlexUser,
            'deviceid': entrypoint.resetDeviceId,
            'delete': entrypoint.deleteItem,
            'browseplex': entrypoint.BrowsePlexContent,
            'ondeck': entrypoint.getOnDeck,
            'chooseServer': entrypoint.chooseServer,
            'watchlater': entrypoint.watchlater,
            'enterPMS': entrypoint.enterPMS,
            'togglePlexTV': entrypoint.togglePlexTV,
            'playwatchlater': entrypoint.playWatchLater
        }

        if "/extrafanart" in sys.argv[0]:
            plexpath = sys.argv[2][1:]
            plexid = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(plexid, plexpath)
            entrypoint.getVideoFiles(plexid, plexpath)
            return

        if mode == 'fanart':
            log.info('User requested fanarttv refresh')
            utils.window('plex_runLibScan', value='fanart')

        # Called by e.g. 3rd party plugin video extras
        if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]
                or "/Extras" in sys.argv[2]):
            plexId = params.get('id', [None])[0]
            entrypoint.getVideoFiles(plexId, params)

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                # modes[mode](itemid, dbid)
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)

            elif mode in ("channels", "getsubfolders"):
                modes[mode](itemid)

            elif mode == "browsecontent":
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('folderid', [""])[0])

            elif mode == 'browseplex':
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('folderid', [""])[0])

            elif mode in ('ondeck', 'recentepisodes'):
                modes[mode](itemid, params.get('type', [""])[0],
                            params.get('tagname', [""])[0],
                            int(params.get('limit', [""])[0]))

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            elif mode == "companion":
                modes[mode](itemid, params=sys.argv[2])
            elif mode == 'playwatchlater':
                modes[mode](params.get('id')[0], params.get('viewOffset')[0])
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin(
                    'Addon.OpenSettings(plugin.video.plexkodiconnect)')
            elif mode in ("manualsync", "repair"):
                if utils.window('plex_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(
                        "PlexKodiConnect",
                        "Unable to run the sync, the add-on is not connected "
                        "to a Plex server.")
                    log.error("Not connected to a PMS.")
                else:
                    if mode == 'repair':
                        utils.window('plex_runLibScan', value="repair")
                        log.info("Requesting repair lib sync")
                    elif mode == 'manualsync':
                        log.info("Requesting full library scan")
                        utils.window('plex_runLibScan', value="full")

            elif mode == "texturecache":
                utils.window('plex_runLibScan', value='del_textures')
            else:
                entrypoint.doMainListing()
Exemple #11
0
    def __init__(self):
        log.debug('Full sys.argv received: %s' % argv)
        # Parse parameters
        params = dict(parse_qsl(argv[2][1:]))
        mode = params.get('mode', '')
        itemid = params.get('id', '')

        if mode == 'play':
            self.play()

        elif mode == 'plex_node':
            self.play()

        elif mode == 'ondeck':
            entrypoint.getOnDeck(itemid,
                                 params.get('type'),
                                 params.get('tagname'),
                                 int(params.get('limit')))

        elif mode == 'recentepisodes':
            entrypoint.getRecentEpisodes(itemid,
                                         params.get('type'),
                                         params.get('tagname'),
                                         int(params.get('limit')))

        elif mode == 'nextup':
            entrypoint.getNextUpEpisodes(params['tagname'],
                                         int(params['limit']))

        elif mode == 'inprogressepisodes':
            entrypoint.getInProgressEpisodes(params['tagname'],
                                             int(params['limit']))

        elif mode == 'browseplex':
            entrypoint.browse_plex(key=params.get('key'),
                                   plex_section_id=params.get('id'))

        elif mode == 'getsubfolders':
            entrypoint.GetSubFolders(itemid)

        elif mode == 'watchlater':
            entrypoint.watchlater()

        elif mode == 'channels':
            entrypoint.channels()

        elif mode == 'settings':
            executebuiltin('Addon.OpenSettings(%s)' % v.ADDON_ID)

        elif mode == 'enterPMS':
            entrypoint.enterPMS()

        elif mode == 'reset':
            reset()

        elif mode == 'togglePlexTV':
            entrypoint.togglePlexTV()

        elif mode == 'resetauth':
            entrypoint.resetAuth()

        elif mode == 'passwords':
            passwordsXML()

        elif mode == 'switchuser':
            entrypoint.switchPlexUser()

        elif mode in ('manualsync', 'repair'):
            if window('plex_online') != 'true':
                # Server is not online, do not run the sync
                dialog('ok',
                       heading=lang(29999),
                       message=lang(39205))
                log.error('Not connected to a PMS.')
            else:
                if mode == 'repair':
                    window('plex_runLibScan', value='repair')
                    log.info('Requesting repair lib sync')
                elif mode == 'manualsync':
                    log.info('Requesting full library scan')
                    window('plex_runLibScan', value='full')

        elif mode == 'texturecache':
            window('plex_runLibScan', value='del_textures')

        elif mode == 'chooseServer':
            entrypoint.chooseServer()

        elif mode == 'refreshplaylist':
            log.info('Requesting playlist/nodes refresh')
            window('plex_runLibScan', value='views')

        elif mode == 'deviceid':
            self.deviceid()

        elif mode == 'fanart':
            log.info('User requested fanarttv refresh')
            window('plex_runLibScan', value='fanart')

        elif '/extrafanart' in argv[0]:
            plexpath = argv[2][1:]
            plexid = itemid
            entrypoint.getExtraFanArt(plexid, plexpath)
            entrypoint.getVideoFiles(plexid, plexpath)

        # Called by e.g. 3rd party plugin video extras
        elif ('/Extras' in argv[0] or '/VideoFiles' in argv[0] or
                '/Extras' in argv[2]):
            plexId = itemid or None
            entrypoint.getVideoFiles(plexId, params)

        else:
            entrypoint.doMainListing(content_type=params.get('content_type'))
    def __init__(self):
        log.debug("Full sys.argv received: %s" % ARGV)
        # Parse parameters
        params = dict(parse_qsl(ARGV[2][1:]))
        try:
            mode = params['mode']
            itemid = params.get('id', '')
        except:
            mode = ""
            itemid = ''

        if mode == 'play':
            # Put the request into the "queue"
            while window('plex_play_new_item'):
                sleep(20)
            window('plex_play_new_item', value='%s%s' % (mode, ARGV[2]))
            # Wait for the result
            while not pickl_window('plex_result'):
                sleep(20)
            result = unpickle_me()
            if result is None:
                log.error('Error encountered, aborting')
                setResolvedUrl(HANDLE, False, ListItem())
            elif result.listitem:
                listitem = convert_PKC_to_listitem(result.listitem)
                setResolvedUrl(HANDLE, True, listitem)
            return

        modes = {
            'reset': reset,
            'resetauth': entrypoint.resetAuth,
            'passwords': passwordsXML,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'switchuser': entrypoint.switchPlexUser,
            'deviceid': entrypoint.resetDeviceId,
            'browseplex': entrypoint.BrowsePlexContent,
            'ondeck': entrypoint.getOnDeck,
            'chooseServer': entrypoint.chooseServer,
            'watchlater': entrypoint.watchlater,
            'enterPMS': entrypoint.enterPMS,
            'togglePlexTV': entrypoint.togglePlexTV,
            'Plex_Node': entrypoint.Plex_Node
        }

        if "/extrafanart" in ARGV[0]:
            plexpath = ARGV[2][1:]
            plexid = params.get('id')
            entrypoint.getExtraFanArt(plexid, plexpath)
            entrypoint.getVideoFiles(plexid, plexpath)
            return

        if mode == 'fanart':
            log.info('User requested fanarttv refresh')
            window('plex_runLibScan', value='fanart')

        # Called by e.g. 3rd party plugin video extras
        if ("/Extras" in ARGV[0] or "/VideoFiles" in ARGV[0]
                or "/Extras" in ARGV[2]):
            plexId = params.get('id', None)
            entrypoint.getVideoFiles(plexId, params)

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                # modes[mode](itemid, dbid)
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes"):
                limit = int(params['limit'])
                modes[mode](itemid, limit)

            elif mode in ("channels", "getsubfolders"):
                modes[mode](itemid)

            elif mode == "browsecontent":
                modes[mode](itemid, params.get('type'), params.get('folderid'))

            elif mode == 'browseplex':
                modes[mode](itemid, params.get('type'), params.get('folderid'))

            elif mode in ('ondeck', 'recentepisodes'):
                modes[mode](itemid, params.get('type'), params.get('tagname'),
                            int(params.get('limit')))

            elif mode == "channelsfolder":
                folderid = params['folderid']
                modes[mode](itemid, folderid)
            elif mode == "companion":
                modes[mode](itemid, params=ARGV[2])
            elif mode == 'Plex_Node':
                modes[mode](params.get('id'), params.get('viewOffset'),
                            params.get('plex_type'))
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                executebuiltin(
                    'Addon.OpenSettings(plugin.video.plexkodiconnect)')
            elif mode in ("manualsync", "repair"):
                if window('plex_online') != "true":
                    # Server is not online, do not run the sync
                    Dialog().ok(
                        lang(29999),
                        "Unable to run the sync, the add-on is not connected "
                        "to a Plex server.")
                    log.error("Not connected to a PMS.")
                else:
                    if mode == 'repair':
                        window('plex_runLibScan', value="repair")
                        log.info("Requesting repair lib sync")
                    elif mode == 'manualsync':
                        log.info("Requesting full library scan")
                        window('plex_runLibScan', value="full")
            elif mode == "texturecache":
                window('plex_runLibScan', value='del_textures')
            else:
                entrypoint.doMainListing()
    def __init__(self):
        # Parse parameters
        log.warn("Full sys.argv received: %s" % sys.argv)
        base_url = sys.argv[0]
        params = urlparse.parse_qs(sys.argv[2][1:])
        try:
            mode = params['mode'][0]
            itemid = params.get('id', '')
            if itemid:
                try:
                    itemid = itemid[0]
                except:
                    pass
        except:
            params = {}
            mode = ""

        modes = {

            'reset': utils.reset,
            'resetauth': entrypoint.resetAuth,
            'play': entrypoint.doPlayback,
            'passwords': utils.passwordsXML,
            'channels': entrypoint.BrowseChannels,
            'channelsfolder': entrypoint.BrowseChannels,
            'browsecontent': entrypoint.BrowseContent,
            'getsubfolders': entrypoint.GetSubFolders,
            'nextup': entrypoint.getNextUpEpisodes,
            'inprogressepisodes': entrypoint.getInProgressEpisodes,
            'recentepisodes': entrypoint.getRecentEpisodes,
            'refreshplaylist': entrypoint.refreshPlaylist,
            'companion': entrypoint.plexCompanion,
            'switchuser': entrypoint.switchPlexUser,
            'deviceid': entrypoint.resetDeviceId,
            'delete': entrypoint.deleteItem,
            'browseplex': entrypoint.BrowsePlexContent,
            'ondeck': entrypoint.getOnDeck,
            'chooseServer': entrypoint.chooseServer,
            'watchlater': entrypoint.watchlater,
            'enterPMS': entrypoint.enterPMS,
            'togglePlexTV': entrypoint.togglePlexTV,
            'playwatchlater': entrypoint.playWatchLater
        }

        if "/extrafanart" in sys.argv[0]:
            plexpath = sys.argv[2][1:]
            plexid = params.get('id', [""])[0]
            entrypoint.getExtraFanArt(plexid, plexpath)
            entrypoint.getVideoFiles(plexid, plexpath)
            return

        if mode == 'fanart':
            log.info('User requested fanarttv refresh')
            utils.window('plex_runLibScan', value='fanart')

        # Called by e.g. 3rd party plugin video extras
        if ("/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0] or
                "/Extras" in sys.argv[2]):
            plexId = params.get('id', [None])[0]
            entrypoint.getVideoFiles(plexId, params)

        if modes.get(mode):
            # Simple functions
            if mode == "play":
                dbid = params.get('dbid')
                # modes[mode](itemid, dbid)
                modes[mode](itemid, dbid)

            elif mode in ("nextup", "inprogressepisodes"):
                limit = int(params['limit'][0])
                modes[mode](itemid, limit)
            
            elif mode in ("channels","getsubfolders"):
                modes[mode](itemid)
                
            elif mode == "browsecontent":
                modes[mode](itemid, params.get('type',[""])[0], params.get('folderid',[""])[0])

            elif mode == 'browseplex':
                modes[mode](
                    itemid,
                    params.get('type', [""])[0],
                    params.get('folderid', [""])[0])

            elif mode in ('ondeck', 'recentepisodes'):
                modes[mode](
                    itemid,
                    params.get('type', [""])[0],
                    params.get('tagname', [""])[0],
                    int(params.get('limit', [""])[0]))

            elif mode == "channelsfolder":
                folderid = params['folderid'][0]
                modes[mode](itemid, folderid)
            elif mode == "companion":
                modes[mode](itemid, params=sys.argv[2])
            elif mode == 'playwatchlater':
                modes[mode](params.get('id')[0], params.get('viewOffset')[0])
            else:
                modes[mode]()
        else:
            # Other functions
            if mode == "settings":
                xbmc.executebuiltin('Addon.OpenSettings(plugin.video.plexkodiconnect)')
            elif mode in ("manualsync", "repair"):
                if utils.window('plex_online') != "true":
                    # Server is not online, do not run the sync
                    xbmcgui.Dialog().ok(
                        "PlexKodiConnect",
                        "Unable to run the sync, the add-on is not connected "
                        "to a Plex server.")
                    log.error("Not connected to a PMS.")
                else:
                    if mode == 'repair':
                        utils.window('plex_runLibScan', value="repair")
                        log.info("Requesting repair lib sync")
                    elif mode == 'manualsync':
                        log.info("Requesting full library scan")
                        utils.window('plex_runLibScan', value="full")
                    
            elif mode == "texturecache":
                utils.window('plex_runLibScan', value='del_textures')
            else:
                entrypoint.doMainListing()
        # Prevent Kodi from hanging in an infinite loop waiting for more
        xbmcplugin.endOfDirectory(int(sys.argv[1]))