Assume its us playing if the PMS is not ours

This commit is contained in:
tomkat83 2016-04-13 15:27:02 +02:00
parent 7f9542c531
commit a594daeb68
3 changed files with 45 additions and 35 deletions

View file

@ -217,6 +217,7 @@ class InitialSetup():
# Write to Kodi settings file
utils.settings('plex_machineIdentifier', activeServer)
utils.settings('plex_servername', server['name'])
utils.settings('plex_serverowned', server['owned'])
if server['local'] == '1':
scheme = server['scheme']
utils.settings('ipaddress', server['ip'])

View file

@ -1436,22 +1436,35 @@ class LibrarySync(Thread):
if state == 'buffering':
continue
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')
# Do we already have a sessionKey stored?
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(
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)
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
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'):
@ -1463,19 +1476,14 @@ class LibrarySync(Thread):
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'
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)
if kodiInfo is None:
# Item not (yet) in Kodi library
continue
# Get an up-to-date XML from the PMS
# because PMS will NOT directly tell us:
# duration of item

View file

@ -181,6 +181,7 @@ class UserClient(threading.Thread):
window('plex_machineIdentifier', value=self.machineIdentifier)
window('plex_servername', value=self.servername)
window('plex_authenticated', value='true')
window('plex_serverowned', value=settings('plex_serverowned'))
window('useDirectPaths', value='true'
if utils.settings('useDirectPaths') == "1" else 'false')