diff --git a/resources/lib/command_pipeline.py b/resources/lib/command_pipeline.py index 2d6dcb35..64fc799c 100644 --- a/resources/lib/command_pipeline.py +++ b/resources/lib/command_pipeline.py @@ -61,6 +61,11 @@ class Monitor_Window(Thread): state.SUSPEND_USER_CLIENT = False elif value.startswith('PLEX_TOKEN-'): state.PLEX_TOKEN = value.replace('PLEX_TOKEN-', '') or None + elif value.startswith('PLEX_USERNAME-'): + state.PLEX_USERNAME = \ + value.replace('PLEX_USERNAME-', '') or None + else: + raise NotImplementedError('%s not implemented' % value) else: sleep(50) # Put one last item into the queue to let playback_starter end diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 3bdfac4d..f690bc01 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -82,7 +82,7 @@ def togglePlexTV(): window('plex_token', clear=True) plex_command('PLEX_TOKEN', '') - window('plex_username', clear=True) + plex_command('PLEX_USERNAME', '') else: log.info('Login to plex.tv') import initialsetup @@ -147,7 +147,7 @@ def doMainListing(content_type=None): addDirectoryItem(lang(30173), "plugin://%s?mode=channels" % v.ADDON_ID) # Plex user switch - addDirectoryItem(lang(39200) + window('plex_username'), + addDirectoryItem(lang(39200), "plugin://%s?mode=switchuser" % v.ADDON_ID) # some extra entries for settings and stuff diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index bbcf5263..4f67d542 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1354,10 +1354,10 @@ class LibrarySync(Thread): pass elif not (currSess['userId'] == state.CURRENT_USER_ID or - currSess['username'] == window('plex_username')): + currSess['username'] == state.PLEX_USERNAME): log.debug('Our username %s, userid %s did not match ' 'the session username %s with userid %s' - % (window('plex_username'), + % (state.PLEX_USERNAME, state.CURRENT_USER_ID, currSess['username'], currSess['userId'])) @@ -1396,7 +1396,7 @@ class LibrarySync(Thread): 'lastViewedAt': DateToKodi(getUnixTimestamp()) }) log.debug('Update playstate for user %s with id %s: %s' - % (window('plex_username'), + % (state.PLEX_USERNAME, state.CURRENT_USER_ID, items[-1])) # Now tell Kodi where we are diff --git a/resources/lib/state.py b/resources/lib/state.py index 2e9784f7..684e1aad 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -27,4 +27,5 @@ DIRECT_PATHS = False AUTHENTICATED = False PLEX_TOKEN = None # Plex ID of the current user (e.g. for plex.tv) as a STRING +PLEX_USERNAME = None CURRENT_USER_ID = None diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 34d7948f..fa6d9a51 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -143,7 +143,7 @@ class UserClient(threading.Thread): # Set to windows property state.CURRENT_USER_ID = userId or None - window('plex_username', value=username) + state.PLEX_USERNAME = username # This is the token for the current PMS (might also be '') window('pms_token', value=self.currToken) # This is the token for plex.tv for the current user @@ -275,7 +275,7 @@ class UserClient(threading.Thread): window('plex_machineIdentifier', clear=True) window('plex_servername', clear=True) state.CURRENT_USER_ID = None - window('plex_username', clear=True) + state.PLEX_USERNAME = None window('plex_restricteduser', clear=True) state.RESTRICTED_USER = False diff --git a/service.py b/service.py index e35b96ee..ec8ca54a 100644 --- a/service.py +++ b/service.py @@ -110,7 +110,7 @@ class Service(): "plex_dbCheck", "plex_kodiScan", "plex_shouldStop", "plex_dbScan", "plex_initialScan", "plex_customplayqueue", "plex_playbackProps", - "plex_runLibScan", "plex_username", "pms_token", "plex_token", + "plex_runLibScan", "pms_token", "plex_token", "pms_server", "plex_machineIdentifier", "plex_servername", "plex_authenticated", "PlexUserImage", "useDirectPaths", "kodiplextimeoffset", "countError", "countUnauthorized",