Add state for Plex user ID

This commit is contained in:
tomkat83 2017-05-17 15:57:30 +02:00
parent ae6057cd36
commit bfe174dc09
8 changed files with 12 additions and 15 deletions

View file

@ -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):

View file

@ -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:

View file

@ -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')

View file

@ -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) = \

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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",