Exemplo n.º 1
0
    def __init__(self):
        # Initial logging
        LOG.info("======== START %s ========", v.ADDON_NAME)
        LOG.info("Platform: %s", v.PLATFORM)
        LOG.info("KODI Version: %s", v.KODILONGVERSION)
        LOG.info("%s Version: %s", v.ADDON_NAME, v.ADDON_VERSION)
        LOG.info("PKC Direct Paths: %s", settings('useDirectPaths') == "true")
        LOG.info("Number of sync threads: %s", settings('syncThreadNumber'))
        LOG.info("Full sys.argv received: %s", argv)

        # Reset window props for profile switch
        properties = [
            "plex_online", "plex_serverStatus", "plex_onWake",
            "plex_kodiScan",
            "plex_shouldStop", "plex_dbScan",
            "plex_initialScan", "plex_customplayqueue", "plex_playbackProps",
            "pms_token", "plex_token",
            "pms_server", "plex_machineIdentifier", "plex_servername",
            "plex_authenticated", "PlexUserImage", "useDirectPaths",
            "countError", "countUnauthorized",
            "plex_restricteduser", "plex_allows_mediaDeletion",
            "plex_command", "plex_result", "plex_force_transcode_pix"
        ]
        for prop in properties:
            window(prop, clear=True)

        # Clear video nodes properties
        videonodes.VideoNodes().clearProperties()

        # Init some stuff
        state.VERIFY_SSL_CERT = settings('sslverify') == 'true'
        state.SSL_CERT_PATH = settings('sslcert') \
            if settings('sslcert') != 'None' else None
        state.FULL_SYNC_INTERVALL = int(settings('fullSyncInterval')) * 60
        state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber'))
        state.SYNC_DIALOG = settings('dbSyncIndicator') == 'true'
        state.ENABLE_MUSIC = settings('enableMusic') == 'true'
        state.BACKGROUND_SYNC = settings(
            'enableBackgroundSync') == 'true'
        state.BACKGROUNDSYNC_SAFTYMARGIN = int(
            settings('backgroundsync_saftyMargin'))
        state.REPLACE_SMB_PATH = settings('replaceSMB') == 'true'
        state.REMAP_PATH = settings('remapSMB') == 'true'
        set_replace_paths()
        state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset'))

        window('plex_minDBVersion', value="2.0.0")
        set_webserver()
        self.monitor = Monitor()
        window('plex_kodiProfile',
               value=tryDecode(translatePath("special://profile")))
        window('fetch_pms_item_number',
               value=settings('fetch_pms_item_number'))
        clientinfo.getDeviceId()
Exemplo n.º 2
0
    def startSession(self, reset=False):
        """
        User should be authenticated when this method is called (via
        userclient)
        """
        # Start session
        self.s = requests.Session()

        self.deviceId = client.getDeviceId()
        # Attach authenticated header to the session
        self.s.headers = client.getXArgsDeviceInfo()
        self.s.encoding = 'utf-8'
        # Set SSL settings
        self.setSSL()

        # Set other stuff
        self.setServer(window('pms_server'))
        self.setToken(window('pms_token'))
        self.setUserId(window('currUserId'))
        self.setUsername(window('plex_username'))

        # Counters to declare PMS dead or unauthorized
        # Use window variables because start of movies will be called with a
        # new plugin instance - it's impossible to share data otherwise
        if reset is True:
            window('countUnauthorized', value='0')
            window('countError', value='0')

        # Retry connections to the server
        self.s.mount("http://", requests.adapters.HTTPAdapter(max_retries=1))
        self.s.mount("https://", requests.adapters.HTTPAdapter(max_retries=1))

        log.info("Requests session started on: %s" % self.server)
Exemplo n.º 3
0
    def startSession(self, reset=False):
        """
        User should be authenticated when this method is called (via
        userclient)
        """
        # Start session
        self.s = requests.Session()

        self.deviceId = client.getDeviceId()
        # Attach authenticated header to the session
        self.s.headers = client.getXArgsDeviceInfo()
        self.s.encoding = 'utf-8'
        # Set SSL settings
        self.setSSL()

        # Set other stuff
        self.setServer(window('pms_server'))
        self.setToken(window('pms_token'))
        self.setUserId(window('currUserId'))
        self.setUsername(window('plex_username'))

        # Counters to declare PMS dead or unauthorized
        # Use window variables because start of movies will be called with a
        # new plugin instance - it's impossible to share data otherwise
        if reset is True:
            window('countUnauthorized', value='0')
            window('countError', value='0')

        # Retry connections to the server
        self.s.mount("http://", requests.adapters.HTTPAdapter(max_retries=1))
        self.s.mount("https://", requests.adapters.HTTPAdapter(max_retries=1))

        log.info("Requests session started on: %s" % self.server)
Exemplo n.º 4
0
def reload_pkc():
    """
    Will reload state.py entirely and then initiate some values from the Kodi
    settings file
    """
    LOG.info('Start (re-)loading PKC settings')
    # Reset state.py
    reload(state)
    # Reset window props
    for prop in WINDOW_PROPERTIES:
        window(prop, clear=True)
    # Clear video nodes properties
    VideoNodes().clearProperties()

    # Initializing
    state.VERIFY_SSL_CERT = settings('sslverify') == 'true'
    state.SSL_CERT_PATH = settings('sslcert') \
        if settings('sslcert') != 'None' else None
    state.FULL_SYNC_INTERVALL = int(settings('fullSyncInterval')) * 60
    state.SYNC_THREAD_NUMBER = int(settings('syncThreadNumber'))
    state.SYNC_DIALOG = settings('dbSyncIndicator') == 'true'
    state.ENABLE_MUSIC = settings('enableMusic') == 'true'
    state.BACKGROUND_SYNC = settings('enableBackgroundSync') == 'true'
    state.BACKGROUNDSYNC_SAFTYMARGIN = int(
        settings('backgroundsync_saftyMargin'))
    state.REPLACE_SMB_PATH = settings('replaceSMB') == 'true'
    state.REMAP_PATH = settings('remapSMB') == 'true'
    state.KODI_PLEX_TIME_OFFSET = float(settings('kodiplextimeoffset'))
    state.FETCH_PMS_ITEM_NUMBER = settings('fetch_pms_item_number')
    # Init some Queues()
    state.COMMAND_PIPELINE_QUEUE = Queue()
    state.COMPANION_QUEUE = Queue(maxsize=100)
    state.WEBSOCKET_QUEUE = Queue()
    set_replace_paths()
    set_webserver()
    # To detect Kodi profile switches
    window('plex_kodiProfile',
           value=try_decode(translatePath("special://profile")))
    getDeviceId()
    # Initialize the PKC playqueues
    PQ.init_playqueues()
    LOG.info('Done (re-)loading PKC settings')
Exemplo n.º 5
0
 def deviceid(self):
     deviceId_old = window('plex_client_Id')
     from clientinfo import getDeviceId
     try:
         deviceId = getDeviceId(reset=True)
     except Exception as e:
         log.error('Failed to generate a new device Id: %s' % e)
         dialog('ok', lang(29999), 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'
         dialog('ok', lang(29999), lang(33033))
         executebuiltin('RestartApp')
Exemplo n.º 6
0
 def deviceid(self):
     deviceId_old = window('plex_client_Id')
     from clientinfo import getDeviceId
     try:
         deviceId = getDeviceId(reset=True)
     except Exception as e:
         log.error('Failed to generate a new device Id: %s' % e)
         dialog('ok', lang(29999), 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'
         dialog('ok', lang(29999), lang(33033))
         executebuiltin('RestartApp')