Enforce PMS authentication before playback start

This commit is contained in:
tomkat83 2016-03-14 10:40:49 +01:00
parent 6a1d3c9ab7
commit 2f9b94d621
5 changed files with 19 additions and 7 deletions

View file

@ -379,6 +379,7 @@
<string id="39207">Reseting PMS connections, please wait</string> <string id="39207">Reseting PMS connections, please wait</string>
<string id="39208">Failed to reset PMS and plex.tv connects. Try to restart Kodi.</string> <string id="39208">Failed to reset PMS and plex.tv connects. Try to restart Kodi.</string>
<string id="39209">[COLOR yellow]Log-in to plex.tv[/COLOR]</string> <string id="39209">[COLOR yellow]Log-in to plex.tv[/COLOR]</string>
<string id="39210">Not yet connected to Plex Server</string>
<!-- Plex Artwork.py --> <!-- Plex Artwork.py -->

View file

@ -310,8 +310,7 @@
<string id="39207">PMS Verbindungen werden zurückgesetzt</string> <string id="39207">PMS Verbindungen werden zurückgesetzt</string>
<string id="39208">PMS und plex.tv Verbindungen konnten nicht zurückgesetzt werden. Bitte versuchen Sie, Kodi neu zu starten, um das Problem zu beheben.</string> <string id="39208">PMS und plex.tv Verbindungen konnten nicht zurückgesetzt werden. Bitte versuchen Sie, Kodi neu zu starten, um das Problem zu beheben.</string>
<string id="39209">[COLOR yellow]Bei plex.tv einloggen[/COLOR]</string> <string id="39209">[COLOR yellow]Bei plex.tv einloggen[/COLOR]</string>
<string id="39210">Noch nicht mit Plex Server verbunden</string>
<!-- Plex Artwork.py --> <!-- Plex Artwork.py -->
<string id="39250">Alle Plex Bilder in Kodi zwischenzuspeichern kann sehr lange dauern. Möchten Sie wirklich fortfahren?</string> <string id="39250">Alle Plex Bilder in Kodi zwischenzuspeichern kann sehr lange dauern. Möchten Sie wirklich fortfahren?</string>

View file

@ -159,6 +159,18 @@ def doPlayback(itemid, dbid):
""" """
Called only for a SINGLE element, not playQueues Called only for a SINGLE element, not playQueues
""" """
if utils.window('plex_authenticated') != "true":
utils.logMsg('doPlayback', 'Not yet authenticated for a PMS, abort '
'starting playback', -1)
string = xbmcaddon.Addon().getLocalizedString
# Not yet connected to a PMS server
xbmcgui.Dialog().notification(
heading=addonName,
message=string(39210),
icon=xbmcgui.NOTIFICATION_ERROR,
time=7000,
sound=True)
return False
item = PlexFunctions.GetPlexMetadata(itemid) item = PlexFunctions.GetPlexMetadata(itemid)
if item is None: if item is None:

View file

@ -179,9 +179,6 @@ class UserClient(threading.Thread):
if authenticated is False: if authenticated is False:
self.logMsg('Testing validity of current token', 0) self.logMsg('Testing validity of current token', 0)
window('currUserId', value=userId)
window('plex_username', value=username)
window('pms_token', value=self.currToken)
res = PlexAPI.PlexAPI().CheckConnection( res = PlexAPI.PlexAPI().CheckConnection(
self.currServer, self.currToken) self.currServer, self.currToken)
if res is False: if res is False:
@ -205,6 +202,7 @@ class UserClient(threading.Thread):
window('pms_server', value=self.currServer) window('pms_server', value=self.currServer)
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')
# Set DownloadUtils values # Set DownloadUtils values
doUtils.setUsername(username) doUtils.setUsername(username)
@ -331,6 +329,7 @@ class UserClient(threading.Thread):
settings = utils.settings settings = utils.settings
window = utils.window window = utils.window
window('plex_authenticated', clear=True)
window('pms_token', clear=True) window('pms_token', clear=True)
window('plex_token', clear=True) window('plex_token', clear=True)
window('pms_server', clear=True) window('pms_server', clear=True)
@ -410,7 +409,7 @@ class UserClient(threading.Thread):
self.auth = True self.auth = True
# Minimize CPU load # Minimize CPU load
xbmc.sleep(500) xbmc.sleep(100)
self.doUtils.stopSession() self.doUtils.stopSession()
log("##===---- UserClient Stopped ----===##", 0) log("##===---- UserClient Stopped ----===##", 0)

View file

@ -78,7 +78,8 @@ class Service():
"emby_shouldStop", "currUserId", "emby_dbScan", "emby_sessionId", "emby_shouldStop", "currUserId", "emby_dbScan", "emby_sessionId",
"emby_initialScan", "emby_customplaylist", "emby_playbackProps", "emby_initialScan", "emby_customplaylist", "emby_playbackProps",
"plex_runLibScan", "plex_username", "pms_token", "plex_token", "plex_runLibScan", "plex_username", "pms_token", "plex_token",
"pms_server", "plex_machineIdentifier", "plex_servername" "pms_server", "plex_machineIdentifier", "plex_servername",
"plex_authenticated"
] ]
for prop in properties: for prop in properties:
window(prop, clear=True) window(prop, clear=True)