Also check authentication via state

This commit is contained in:
tomkat83 2017-05-12 15:32:46 +02:00
parent 071c68969a
commit e5a422635d
4 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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