Assume its us playing if the PMS is not ours
This commit is contained in:
parent
7f9542c531
commit
a594daeb68
3 changed files with 45 additions and 35 deletions
|
@ -217,6 +217,7 @@ class InitialSetup():
|
||||||
# Write to Kodi settings file
|
# Write to Kodi settings file
|
||||||
utils.settings('plex_machineIdentifier', activeServer)
|
utils.settings('plex_machineIdentifier', activeServer)
|
||||||
utils.settings('plex_servername', server['name'])
|
utils.settings('plex_servername', server['name'])
|
||||||
|
utils.settings('plex_serverowned', server['owned'])
|
||||||
if server['local'] == '1':
|
if server['local'] == '1':
|
||||||
scheme = server['scheme']
|
scheme = server['scheme']
|
||||||
utils.settings('ipaddress', server['ip'])
|
utils.settings('ipaddress', server['ip'])
|
||||||
|
|
|
@ -1436,45 +1436,53 @@ class LibrarySync(Thread):
|
||||||
if state == 'buffering':
|
if state == 'buffering':
|
||||||
continue
|
continue
|
||||||
ratingKey = item.get('ratingKey')
|
ratingKey = item.get('ratingKey')
|
||||||
sessionKey = item.get('sessionKey')
|
|
||||||
# Do we already have a sessionKey stored?
|
|
||||||
if sessionKey not in self.sessionKeys:
|
|
||||||
# No - update our list of all current sessions
|
|
||||||
self.sessionKeys = PF.GetPMSStatus(
|
|
||||||
utils.window('plex_token'))
|
|
||||||
self.logMsg('Updated current sessions. They are: %s'
|
|
||||||
% self.sessionKeys, 2)
|
|
||||||
if sessionKey not in self.sessionKeys:
|
|
||||||
self.logMsg('Session key %s still unknown! Skip item'
|
|
||||||
% sessionKey, 1)
|
|
||||||
continue
|
|
||||||
|
|
||||||
currSess = self.sessionKeys[sessionKey]
|
|
||||||
# Identify the user - same one as signed on with PKC?
|
|
||||||
# Skip update if neither session's username nor userid match
|
|
||||||
# (Owner sometime's returns id '1', not always)
|
|
||||||
if (utils.window('plex_token') == '' and
|
|
||||||
currSess['userId'] == '1'):
|
|
||||||
# PKC not signed in to plex.tv. Plus owner of PMS is
|
|
||||||
# playing (the '1').
|
|
||||||
# Hence must be us (since several users require plex.tv
|
|
||||||
# token for PKC)
|
|
||||||
pass
|
|
||||||
elif not (currSess['userId'] == utils.window('currUserId')
|
|
||||||
or
|
|
||||||
currSess['username'] == utils.window('plex_username')):
|
|
||||||
self.logMsg('Our username %s, userid %s did not match the '
|
|
||||||
'session username %s with userid %s'
|
|
||||||
% (utils.window('plex_username'),
|
|
||||||
utils.window('currUserId'),
|
|
||||||
currSess['username'],
|
|
||||||
currSess['userId']), 2)
|
|
||||||
continue
|
|
||||||
|
|
||||||
kodiInfo = emby_db.getItem_byId(ratingKey)
|
kodiInfo = emby_db.getItem_byId(ratingKey)
|
||||||
if kodiInfo is None:
|
if kodiInfo is None:
|
||||||
# Item not (yet) in Kodi library
|
# Item not (yet) in Kodi library
|
||||||
continue
|
continue
|
||||||
|
sessionKey = item.get('sessionKey')
|
||||||
|
# Do we already have a sessionKey stored?
|
||||||
|
if sessionKey not in self.sessionKeys:
|
||||||
|
if utils.window('plex_serverowned') == '0':
|
||||||
|
# Not our PMS, we are not authorized to get the
|
||||||
|
# sessions
|
||||||
|
# On the bright side, it must be us playing :-)
|
||||||
|
self.sessionKeys = {
|
||||||
|
sessionKey: {}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
# PMS is ours - get all current sessions
|
||||||
|
self.sessionKeys = PF.GetPMSStatus(
|
||||||
|
utils.window('plex_token'))
|
||||||
|
self.logMsg('Updated current sessions. They are: %s'
|
||||||
|
% self.sessionKeys, 2)
|
||||||
|
if sessionKey not in self.sessionKeys:
|
||||||
|
self.logMsg('Session key %s still unknown! Skip '
|
||||||
|
'item' % sessionKey, 1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
currSess = self.sessionKeys[sessionKey]
|
||||||
|
if utils.window('plex_serverowned') != '0':
|
||||||
|
# Identify the user - same one as signed on with PKC? Skip
|
||||||
|
# update if neither session's username nor userid match
|
||||||
|
# (Owner sometime's returns id '1', not always)
|
||||||
|
if (utils.window('plex_token') == '' and
|
||||||
|
currSess['userId'] == '1'):
|
||||||
|
# PKC not signed in to plex.tv. Plus owner of PMS is
|
||||||
|
# playing (the '1').
|
||||||
|
# Hence must be us (since several users require plex.tv
|
||||||
|
# token for PKC)
|
||||||
|
pass
|
||||||
|
elif not (currSess['userId'] == utils.window('currUserId')
|
||||||
|
or
|
||||||
|
currSess['username'] == utils.window('plex_username')):
|
||||||
|
self.logMsg('Our username %s, userid %s did not match '
|
||||||
|
'the session username %s with userid %s'
|
||||||
|
% (utils.window('plex_username'),
|
||||||
|
utils.window('currUserId'),
|
||||||
|
currSess['username'],
|
||||||
|
currSess['userId']), 2)
|
||||||
|
continue
|
||||||
|
|
||||||
# Get an up-to-date XML from the PMS
|
# Get an up-to-date XML from the PMS
|
||||||
# because PMS will NOT directly tell us:
|
# because PMS will NOT directly tell us:
|
||||||
|
|
|
@ -181,6 +181,7 @@ class UserClient(threading.Thread):
|
||||||
window('plex_machineIdentifier', value=self.machineIdentifier)
|
window('plex_machineIdentifier', value=self.machineIdentifier)
|
||||||
window('plex_servername', value=self.servername)
|
window('plex_servername', value=self.servername)
|
||||||
window('plex_authenticated', value='true')
|
window('plex_authenticated', value='true')
|
||||||
|
window('plex_serverowned', value=settings('plex_serverowned'))
|
||||||
|
|
||||||
window('useDirectPaths', value='true'
|
window('useDirectPaths', value='true'
|
||||||
if utils.settings('useDirectPaths') == "1" else 'false')
|
if utils.settings('useDirectPaths') == "1" else 'false')
|
||||||
|
|
Loading…
Reference in a new issue