Exemple #1
0
 def deviceid():
     deviceId_old = pickler.pickl_window('plex_client_Id')
     from resources.lib import clientinfo
     try:
         deviceId = clientinfo.getDeviceId(reset=True)
     except Exception as e:
         log.error('Failed to generate a new device Id: %s' % e)
         utils.messageDialog(utils.lang(29999), utils.lang(33032))
     else:
         log.info('Successfully removed old device ID: %s New deviceId:'
                  '%s' % (deviceId_old, deviceId))
         # 'Kodi will now restart to apply the changes'
         utils.messageDialog(utils.lang(29999), utils.lang(33033))
         executebuiltin('RestartApp')
Exemple #2
0
 def play():
     """
     Start up playback_starter in main Python thread
     """
     request = '%s&handle=%s' % (argv[2], HANDLE)
     # Put the request into the 'queue'
     transfer.plex_command('PLAY-%s' % request)
     if HANDLE == -1:
         # Handle -1 received, not waiting for main thread
         return
     # Wait for the result from the main PKC thread
     result = transfer.wait_for_transfer()
     if result is None:
         LOG.error('Error encountered, aborting')
         utils.dialog('notification',
                      heading='{plex}',
                      message=utils.lang(30128),
                      icon='{error}',
                      time=3000)
         xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
     elif result is True:
         pass
     else:
         # Received a xbmcgui.ListItem()
         xbmcplugin.setResolvedUrl(HANDLE, True, result)
Exemple #3
0
 def play():
     """
     Start up playback_starter in main Python thread
     """
     request = '%s&handle=%s' % (argv[2], HANDLE)
     # Put the request into the 'queue'
     utils.plex_command('PLAY-%s' % request)
     if HANDLE == -1:
         # Handle -1 received, not waiting for main thread
         return
     # Wait for the result
     while not pickler.pickl_window('plex_result'):
         sleep(50)
     result = pickler.unpickle_me()
     if result is None:
         log.error('Error encountered, aborting')
         utils.dialog('notification',
                      heading='{plex}',
                      message=utils.lang(30128),
                      icon='{error}',
                      time=3000)
         setResolvedUrl(HANDLE, False, ListItem())
     elif result.listitem:
         listitem = pkc_listitem.convert_pkc_to_listitem(result.listitem)
         setResolvedUrl(HANDLE, True, listitem)
Exemple #4
0
    def __init__(self):
        LOG.debug('Full sys.argv received: %s', argv)
        # Parse parameters
        params = dict(parse_qsl(argv[2][1:]))
        arguments = unicode_paths.decode(argv[2])
        path = unicode_paths.decode(argv[0])
        # Ensure unicode
        for key, value in params.iteritems():
            params[key.decode('utf-8')] = params.pop(key)
            params[key] = value.decode('utf-8')
        mode = params.get('mode', '')
        itemid = params.get('id', '')

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

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

        elif mode == 'browseplex':
            entrypoint.browse_plex(key=params.get('key'),
                                   plex_type=params.get('plex_type'),
                                   section_id=params.get('section_id'),
                                   synched=params.get('synched') != 'false',
                                   prompt=params.get('prompt'),
                                   query=params.get('query'))

        elif mode == 'show_section':
            entrypoint.show_section(params.get('section_index'))

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

        elif mode == 'channels':
            entrypoint.browse_plex(key='/channels/all')

        elif mode == 'search':
            # "Search"
            entrypoint.browse_plex(key='/hubs/search',
                                   args={
                                       'includeCollections': 1,
                                       'includeExternalMedia': 1
                                   },
                                   prompt=utils.lang(137),
                                   query=params.get('query'))

        elif mode == 'route_to_extras':
            # Hack so we can store this path in the Kodi DB
            handle = ('plugin://%s?mode=extras&plex_id=%s' %
                      (v.ADDON_ID, params.get('plex_id')))
            if xbmcgui.getCurrentWindowId() == 10025:
                # Video Window
                xbmc.executebuiltin('Container.Update(\"%s\")' % handle)
            else:
                xbmc.executebuiltin('ActivateWindow(videos, \"%s\")' % handle)

        elif mode == 'extras':
            entrypoint.extras(plex_id=params.get('plex_id'))

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

        elif mode == 'enterPMS':
            LOG.info('Request to manually enter new PMS address')
            transfer.plex_command('enter_new_pms_address')

        elif mode == 'reset':
            transfer.plex_command('RESET-PKC')

        elif mode == 'togglePlexTV':
            LOG.info('Toggle of Plex.tv sign-in requested')
            transfer.plex_command('toggle_plex_tv_sign_in')

        elif mode == 'passwords':
            from resources.lib.windows import direct_path_sources
            direct_path_sources.start()

        elif mode == 'switchuser':
            LOG.info('Plex home user switch requested')
            transfer.plex_command('switch_plex_user')

        elif mode in ('manualsync', 'repair'):
            if mode == 'repair':
                LOG.info('Requesting repair lib sync')
                transfer.plex_command('repair-scan')
            elif mode == 'manualsync':
                LOG.info('Requesting full library scan')
                transfer.plex_command('full-scan')

        elif mode == 'texturecache':
            LOG.info('Requesting texture caching of all textures')
            transfer.plex_command('textures-scan')

        elif mode == 'chooseServer':
            LOG.info("Choosing PMS server requested, starting")
            transfer.plex_command('choose_pms_server')

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

        elif mode == 'fanart':
            LOG.info('User requested fanarttv refresh')
            transfer.plex_command('fanart-scan')

        elif '/extrafanart' in path:
            plexpath = arguments[1:]
            plexid = itemid
            entrypoint.extra_fanart(plexid, plexpath)
            entrypoint.get_video_files(plexid, plexpath)

        # Called by e.g. 3rd party plugin video extras
        elif ('/Extras' in path or '/VideoFiles' in path
              or '/Extras' in arguments):
            plexId = itemid or None
            entrypoint.get_video_files(plexId, params)

        elif mode == 'playlists':
            entrypoint.playlists(params.get('content_type'))

        elif mode == 'hub':
            entrypoint.hub(params.get('content_type'))

        elif mode == 'select-libraries':
            LOG.info('User requested to select Plex libraries')
            transfer.plex_command('select-libraries')

        elif mode == 'refreshplaylist':
            LOG.info('User requested to refresh Kodi playlists and nodes')
            transfer.plex_command('refreshplaylist')

        else:
            entrypoint.show_main_menu(content_type=params.get('content_type'))
    def __init__(self):
        log.debug('Full sys.argv received: %s', argv)
        # Parse parameters
        path = unicode_paths.decode(argv[0])
        arguments = unicode_paths.decode(argv[2])
        params = dict(parse_qsl(arguments[1:]))
        mode = params.get('mode', '')
        itemid = params.get('id', '')

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

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

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

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

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

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

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

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

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

        elif mode == 'route_to_extras':
            # Hack so we can store this path in the Kodi DB
            handle = ('plugin://%s?mode=extras&plex_id=%s' %
                      (v.ADDON_ID, params.get('plex_id')))
            if getCurrentWindowId() == 10025:
                # Video Window
                executebuiltin('Container.Update(\"%s\")' % handle)
            else:
                executebuiltin('ActivateWindow(videos, \"%s\")' % handle)

        elif mode == 'extras':
            entrypoint.extras(plex_id=params.get('plex_id'))

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

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

        elif mode == 'reset':
            utils.reset()

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

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

        elif mode == 'passwords':
            utils.passwords_xml()

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

        elif mode in ('manualsync', 'repair'):
            if pickler.pickl_window('plex_online') != 'true':
                # Server is not online, do not run the sync
                utils.messageDialog(utils.lang(29999), utils.lang(39205))
                log.error('Not connected to a PMS.')
            else:
                if mode == 'repair':
                    log.info('Requesting repair lib sync')
                    utils.plex_command('RUN_LIB_SCAN', 'repair')
                elif mode == 'manualsync':
                    log.info('Requesting full library scan')
                    utils.plex_command('RUN_LIB_SCAN', 'full')

        elif mode == 'texturecache':
            log.info('Requesting texture caching of all textures')
            utils.plex_command('RUN_LIB_SCAN', 'textures')

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

        elif mode == 'refreshplaylist':
            log.info('Requesting playlist/nodes refresh')
            utils.plex_command('RUN_LIB_SCAN', 'views')

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

        elif mode == 'fanart':
            log.info('User requested fanarttv refresh')
            utils.plex_command('RUN_LIB_SCAN', 'fanart')

        elif '/extrafanart' in path:
            plexpath = arguments[1:]
            plexid = itemid
            entrypoint.extra_fanart(plexid, plexpath)
            entrypoint.get_video_files(plexid, plexpath)

        # Called by e.g. 3rd party plugin video extras
        elif ('/Extras' in path or '/VideoFiles' in path
              or '/Extras' in arguments):
            plexId = itemid or None
            entrypoint.get_video_files(plexId, params)

        elif mode == 'playlists':
            entrypoint.playlists(params.get('content_type'))

        elif mode == 'hub':
            entrypoint.hub(params.get('type'))

        else:
            entrypoint.show_main_menu(content_type=params.get('content_type'))
def proceed(title, subtitle):
	proceed = True
	if setting('confirm') == 'true':
		proceed = xbmcgui.Dialog().yesno(info('name'), title, lang(30526) % subtitle)
	return proceed
def rating(title):
	l = ['10 **********','9 *********','8 ********','7 *******','6 ******','5 *****','4 ****','3 ***','2 **','1 *']
	i = xbmcgui.Dialog().select(lang(30512) % (info('name'), title), l)
	if not i == -1:
		rating = 10 - i
		return rating
def warning(module, count):
	proceed = True
	threshold = int(setting('fm_warn'))
	if count > threshold:
		proceed = xbmcgui.Dialog().yesno(info('name'), lang(30588) % (module, count))
	return proceed