diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index f997c883..4cfa311a 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -37,7 +37,6 @@ class Items(object): def __init__(self): self.artwork = artwork.Artwork() - self.userid = window('currUserId') self.server = window('pms_server') def __enter__(self): diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 25e1df1c..bbcf5263 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1352,13 +1352,13 @@ class LibrarySync(Thread): # Hence must be us (since several users require plex.tv # token for PKC) pass - elif not (currSess['userId'] == window('currUserId') + elif not (currSess['userId'] == state.CURRENT_USER_ID or currSess['username'] == window('plex_username')): log.debug('Our username %s, userid %s did not match ' 'the session username %s with userid %s' % (window('plex_username'), - window('currUserId'), + state.CURRENT_USER_ID, currSess['username'], currSess['userId'])) continue @@ -1397,7 +1397,7 @@ class LibrarySync(Thread): }) log.debug('Update playstate for user %s with id %s: %s' % (window('plex_username'), - window('currUserId'), + state.CURRENT_USER_ID, items[-1])) # Now tell Kodi where we are for item in items: diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 6f6415de..1cc97b44 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -24,7 +24,6 @@ class PlayUtils(): self.API = PlexAPI.API(item) self.doUtils = DownloadUtils().downloadUrl - self.userid = window('currUserId') self.server = window('pms_server') self.machineIdentifier = window('plex_machineIdentifier') diff --git a/resources/lib/plexbmchelper/subscribers.py b/resources/lib/plexbmchelper/subscribers.py index b8f4e20b..1f8b8aca 100644 --- a/resources/lib/plexbmchelper/subscribers.py +++ b/resources/lib/plexbmchelper/subscribers.py @@ -79,8 +79,6 @@ class SubscriptionManager: ret += ' />' return ret - # pbmc_server = str(WINDOW.getProperty('plexbmc.nowplaying.server')) - # userId = str(WINDOW.getProperty('currUserId')) pbmc_server = window('pms_server') if pbmc_server: (self.protocol, self.server, self.port) = \ diff --git a/resources/lib/state.py b/resources/lib/state.py index 6bbec4e3..2e9784f7 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -22,6 +22,9 @@ RESTRICTED_USER = False # Direct Paths (True) or Addon Paths (False)? Along with # window('useDirectPaths') DIRECT_PATHS = False + # Along with window('plex_authenticated') AUTHENTICATED = False PLEX_TOKEN = None +# Plex ID of the current user (e.g. for plex.tv) as a STRING +CURRENT_USER_ID = None diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 9d92e550..34d7948f 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -39,7 +39,6 @@ class UserClient(threading.Thread): self.retry = 0 self.currUser = None - self.currUserId = None self.currServer = None self.currToken = None self.HasAccess = True @@ -122,7 +121,6 @@ class UserClient(threading.Thread): log.debug('Loading current user') doUtils = self.doUtils - self.currUserId = userId self.currToken = usertoken self.currServer = self.getServer() self.ssl = self.getSSLverify() @@ -144,7 +142,7 @@ class UserClient(threading.Thread): return False # Set to windows property - window('currUserId', value=userId) + state.CURRENT_USER_ID = userId or None window('plex_username', value=username) # This is the token for the current PMS (might also be '') window('pms_token', value=self.currToken) @@ -276,7 +274,7 @@ class UserClient(threading.Thread): window('pms_server', clear=True) window('plex_machineIdentifier', clear=True) window('plex_servername', clear=True) - window('currUserId', clear=True) + state.CURRENT_USER_ID = None window('plex_username', clear=True) window('plex_restricteduser', clear=True) state.RESTRICTED_USER = False @@ -291,7 +289,6 @@ class UserClient(threading.Thread): self.currToken = None self.auth = True self.currUser = None - self.currUserId = None self.retry = 0 @@ -331,7 +328,7 @@ class UserClient(threading.Thread): # Successfully authenticated and loaded a user log.info("Successfully authenticated!") log.info("Current user: %s" % self.currUser) - log.info("Current userId: %s" % self.currUserId) + log.info("Current userId: %s" % state.CURRENT_USER_ID) self.retry = 0 state.SUSPEND_LIBRARY_THREAD = False window('plex_serverStatus', clear=True) diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index 021cd4cb..93bed8f0 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -221,7 +221,8 @@ class Alexa_Websocket(WebSocket): def getUri(self): self.plex_client_Id = window('plex_client_Id') uri = ('wss://pubsub.plex.tv/sub/websockets/%s/%s?X-Plex-Token=%s' - % (window('currUserId'), self.plex_client_Id, state.PLEX_TOKEN)) + % (state.CURRENT_USER_ID, + self.plex_client_Id, state.PLEX_TOKEN)) sslopt = {} log.debug("Uri: %s, sslopt: %s" % (uri, sslopt)) return uri, sslopt diff --git a/service.py b/service.py index a37d60c1..e35b96ee 100644 --- a/service.py +++ b/service.py @@ -108,7 +108,7 @@ class Service(): properties = [ "plex_online", "plex_serverStatus", "plex_onWake", "plex_dbCheck", "plex_kodiScan", - "plex_shouldStop", "currUserId", "plex_dbScan", + "plex_shouldStop", "plex_dbScan", "plex_initialScan", "plex_customplayqueue", "plex_playbackProps", "plex_runLibScan", "plex_username", "pms_token", "plex_token", "pms_server", "plex_machineIdentifier", "plex_servername",