Add state for Plex username
This commit is contained in:
parent
f2575289b2
commit
9ae68b66f7
6 changed files with 14 additions and 8 deletions
|
@ -61,6 +61,11 @@ class Monitor_Window(Thread):
|
||||||
state.SUSPEND_USER_CLIENT = False
|
state.SUSPEND_USER_CLIENT = False
|
||||||
elif value.startswith('PLEX_TOKEN-'):
|
elif value.startswith('PLEX_TOKEN-'):
|
||||||
state.PLEX_TOKEN = value.replace('PLEX_TOKEN-', '') or None
|
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:
|
else:
|
||||||
sleep(50)
|
sleep(50)
|
||||||
# Put one last item into the queue to let playback_starter end
|
# Put one last item into the queue to let playback_starter end
|
||||||
|
|
|
@ -82,7 +82,7 @@ def togglePlexTV():
|
||||||
|
|
||||||
window('plex_token', clear=True)
|
window('plex_token', clear=True)
|
||||||
plex_command('PLEX_TOKEN', '')
|
plex_command('PLEX_TOKEN', '')
|
||||||
window('plex_username', clear=True)
|
plex_command('PLEX_USERNAME', '')
|
||||||
else:
|
else:
|
||||||
log.info('Login to plex.tv')
|
log.info('Login to plex.tv')
|
||||||
import initialsetup
|
import initialsetup
|
||||||
|
@ -147,7 +147,7 @@ def doMainListing(content_type=None):
|
||||||
addDirectoryItem(lang(30173),
|
addDirectoryItem(lang(30173),
|
||||||
"plugin://%s?mode=channels" % v.ADDON_ID)
|
"plugin://%s?mode=channels" % v.ADDON_ID)
|
||||||
# Plex user switch
|
# Plex user switch
|
||||||
addDirectoryItem(lang(39200) + window('plex_username'),
|
addDirectoryItem(lang(39200),
|
||||||
"plugin://%s?mode=switchuser" % v.ADDON_ID)
|
"plugin://%s?mode=switchuser" % v.ADDON_ID)
|
||||||
|
|
||||||
# some extra entries for settings and stuff
|
# some extra entries for settings and stuff
|
||||||
|
|
|
@ -1354,10 +1354,10 @@ class LibrarySync(Thread):
|
||||||
pass
|
pass
|
||||||
elif not (currSess['userId'] == state.CURRENT_USER_ID
|
elif not (currSess['userId'] == state.CURRENT_USER_ID
|
||||||
or
|
or
|
||||||
currSess['username'] == window('plex_username')):
|
currSess['username'] == state.PLEX_USERNAME):
|
||||||
log.debug('Our username %s, userid %s did not match '
|
log.debug('Our username %s, userid %s did not match '
|
||||||
'the session username %s with userid %s'
|
'the session username %s with userid %s'
|
||||||
% (window('plex_username'),
|
% (state.PLEX_USERNAME,
|
||||||
state.CURRENT_USER_ID,
|
state.CURRENT_USER_ID,
|
||||||
currSess['username'],
|
currSess['username'],
|
||||||
currSess['userId']))
|
currSess['userId']))
|
||||||
|
@ -1396,7 +1396,7 @@ class LibrarySync(Thread):
|
||||||
'lastViewedAt': DateToKodi(getUnixTimestamp())
|
'lastViewedAt': DateToKodi(getUnixTimestamp())
|
||||||
})
|
})
|
||||||
log.debug('Update playstate for user %s with id %s: %s'
|
log.debug('Update playstate for user %s with id %s: %s'
|
||||||
% (window('plex_username'),
|
% (state.PLEX_USERNAME,
|
||||||
state.CURRENT_USER_ID,
|
state.CURRENT_USER_ID,
|
||||||
items[-1]))
|
items[-1]))
|
||||||
# Now tell Kodi where we are
|
# Now tell Kodi where we are
|
||||||
|
|
|
@ -27,4 +27,5 @@ DIRECT_PATHS = False
|
||||||
AUTHENTICATED = False
|
AUTHENTICATED = False
|
||||||
PLEX_TOKEN = None
|
PLEX_TOKEN = None
|
||||||
# Plex ID of the current user (e.g. for plex.tv) as a STRING
|
# Plex ID of the current user (e.g. for plex.tv) as a STRING
|
||||||
|
PLEX_USERNAME = None
|
||||||
CURRENT_USER_ID = None
|
CURRENT_USER_ID = None
|
||||||
|
|
|
@ -143,7 +143,7 @@ class UserClient(threading.Thread):
|
||||||
|
|
||||||
# Set to windows property
|
# Set to windows property
|
||||||
state.CURRENT_USER_ID = userId or None
|
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 '')
|
# This is the token for the current PMS (might also be '')
|
||||||
window('pms_token', value=self.currToken)
|
window('pms_token', value=self.currToken)
|
||||||
# This is the token for plex.tv for the current user
|
# 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_machineIdentifier', clear=True)
|
||||||
window('plex_servername', clear=True)
|
window('plex_servername', clear=True)
|
||||||
state.CURRENT_USER_ID = None
|
state.CURRENT_USER_ID = None
|
||||||
window('plex_username', clear=True)
|
state.PLEX_USERNAME = None
|
||||||
window('plex_restricteduser', clear=True)
|
window('plex_restricteduser', clear=True)
|
||||||
state.RESTRICTED_USER = False
|
state.RESTRICTED_USER = False
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ class Service():
|
||||||
"plex_dbCheck", "plex_kodiScan",
|
"plex_dbCheck", "plex_kodiScan",
|
||||||
"plex_shouldStop", "plex_dbScan",
|
"plex_shouldStop", "plex_dbScan",
|
||||||
"plex_initialScan", "plex_customplayqueue", "plex_playbackProps",
|
"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",
|
"pms_server", "plex_machineIdentifier", "plex_servername",
|
||||||
"plex_authenticated", "PlexUserImage", "useDirectPaths",
|
"plex_authenticated", "PlexUserImage", "useDirectPaths",
|
||||||
"kodiplextimeoffset", "countError", "countUnauthorized",
|
"kodiplextimeoffset", "countError", "countUnauthorized",
|
||||||
|
|
Loading…
Reference in a new issue