From 2615ecfd793e51f744db7dd1a5dabd108d35cc16 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 17 May 2017 10:10:14 +0200 Subject: [PATCH] Revert "Revert "Also check authentication via state"" This reverts commit 05aa97c0adc73fd01c0380313d34b2cca8a33ae6. --- resources/lib/playback_starter.py | 3 ++- resources/lib/state.py | 2 ++ resources/lib/userclient.py | 2 ++ service.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/lib/playback_starter.py b/resources/lib/playback_starter.py index 836f587d..f0ac27f5 100644 --- a/resources/lib/playback_starter.py +++ b/resources/lib/playback_starter.py @@ -17,6 +17,7 @@ import variables as v from downloadutils import DownloadUtils from PKC_listitem import convert_PKC_to_listitem import plexdb_functions as plexdb +import state ############################################################################### log = logging.getLogger("PLEX."+__name__) @@ -39,7 +40,7 @@ class Playback_Starter(Thread): """ log.info("Process_play called with plex_id %s, kodi_id %s" % (plex_id, kodi_id)) - if window('plex_authenticated') != "true": + if not state.AUTHENTICATED: log.error('Not yet authenticated for PMS, abort starting playback') # Todo: Warn user with dialog return diff --git a/resources/lib/state.py b/resources/lib/state.py index 9fffcaea..6d9df0be 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -19,4 +19,6 @@ SUSPEND_USER_CLIENT = False # Plex home user? Then "False". Along with window('plex_restricteduser') RESTRICTED_USER = False +# Along with window('plex_authenticated') +AUTHENTICATED = False PLEX_TOKEN = None diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 584a1d94..5757c702 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -159,6 +159,7 @@ class UserClient(threading.Thread): window('plex_machineIdentifier', value=self.machineIdentifier) window('plex_servername', value=self.servername) window('plex_authenticated', value='true') + state.AUTHENTICATED = True window('useDirectPaths', value='true' if settings('useDirectPaths') == "1" else 'false') @@ -266,6 +267,7 @@ class UserClient(threading.Thread): self.doUtils.stopSession() window('plex_authenticated', clear=True) + state.AUTHENTICATED = False window('pms_token', clear=True) state.PLEX_TOKEN = None window('plex_token', clear=True) diff --git a/service.py b/service.py index 0bfd43b7..a37d60c1 100644 --- a/service.py +++ b/service.py @@ -303,7 +303,7 @@ class Service(): sound=False) log.info("Server %s is online and ready." % server) window('plex_online', value="true") - if window('plex_authenticated') == 'true': + if state.AUTHENTICATED: # Server got offline when we were authenticated. # Hence resume threads state.SUSPEND_LIBRARY_THREAD = False