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,22 +1436,35 @@ class LibrarySync(Thread):
|
||||||
if state == 'buffering':
|
if state == 'buffering':
|
||||||
continue
|
continue
|
||||||
ratingKey = item.get('ratingKey')
|
ratingKey = item.get('ratingKey')
|
||||||
|
kodiInfo = emby_db.getItem_byId(ratingKey)
|
||||||
|
if kodiInfo is None:
|
||||||
|
# Item not (yet) in Kodi library
|
||||||
|
continue
|
||||||
sessionKey = item.get('sessionKey')
|
sessionKey = item.get('sessionKey')
|
||||||
# Do we already have a sessionKey stored?
|
# Do we already have a sessionKey stored?
|
||||||
if sessionKey not in self.sessionKeys:
|
if sessionKey not in self.sessionKeys:
|
||||||
# No - update our list of all current sessions
|
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(
|
self.sessionKeys = PF.GetPMSStatus(
|
||||||
utils.window('plex_token'))
|
utils.window('plex_token'))
|
||||||
self.logMsg('Updated current sessions. They are: %s'
|
self.logMsg('Updated current sessions. They are: %s'
|
||||||
% self.sessionKeys, 2)
|
% self.sessionKeys, 2)
|
||||||
if sessionKey not in self.sessionKeys:
|
if sessionKey not in self.sessionKeys:
|
||||||
self.logMsg('Session key %s still unknown! Skip item'
|
self.logMsg('Session key %s still unknown! Skip '
|
||||||
% sessionKey, 1)
|
'item' % sessionKey, 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
currSess = self.sessionKeys[sessionKey]
|
currSess = self.sessionKeys[sessionKey]
|
||||||
# Identify the user - same one as signed on with PKC?
|
if utils.window('plex_serverowned') != '0':
|
||||||
# Skip update if neither session's username nor userid match
|
# 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)
|
# (Owner sometime's returns id '1', not always)
|
||||||
if (utils.window('plex_token') == '' and
|
if (utils.window('plex_token') == '' and
|
||||||
currSess['userId'] == '1'):
|
currSess['userId'] == '1'):
|
||||||
|
@ -1463,19 +1476,14 @@ class LibrarySync(Thread):
|
||||||
elif not (currSess['userId'] == utils.window('currUserId')
|
elif not (currSess['userId'] == utils.window('currUserId')
|
||||||
or
|
or
|
||||||
currSess['username'] == utils.window('plex_username')):
|
currSess['username'] == utils.window('plex_username')):
|
||||||
self.logMsg('Our username %s, userid %s did not match the '
|
self.logMsg('Our username %s, userid %s did not match '
|
||||||
'session username %s with userid %s'
|
'the session username %s with userid %s'
|
||||||
% (utils.window('plex_username'),
|
% (utils.window('plex_username'),
|
||||||
utils.window('currUserId'),
|
utils.window('currUserId'),
|
||||||
currSess['username'],
|
currSess['username'],
|
||||||
currSess['userId']), 2)
|
currSess['userId']), 2)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
kodiInfo = emby_db.getItem_byId(ratingKey)
|
|
||||||
if kodiInfo is None:
|
|
||||||
# Item not (yet) in Kodi library
|
|
||||||
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:
|
||||||
# duration of item
|
# duration of item
|
||||||
|
|
|
@ -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