From 334206b334539d8cd9b4b419480ed2593109d72b Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 6 Sep 2016 17:43:15 -0500 Subject: [PATCH] Fix user client loading user ordering --- resources/lib/downloadutils.py | 4 +++- resources/lib/initialsetup.py | 2 +- resources/lib/userclient.py | 14 +++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index de05fb5a..bc0084fd 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -136,13 +136,13 @@ class DownloadUtils(): # User is identified from this point # Attach authenticated header to the session - verify = False header = self.getHeader() # If user enabled host certificate verification try: verify = self.sslverify except: + verify = False log.info("Could not load SSL settings.") # Start session @@ -172,6 +172,7 @@ class DownloadUtils(): auth = ( 'MediaBrowser UserId="%s", Client="Kodi", Device="%s", DeviceId="%s", Version="%s"' % (self.userId, deviceName, deviceId, version)) + header = { 'Content-type': 'application/json', @@ -185,6 +186,7 @@ class DownloadUtils(): auth = ( 'MediaBrowser Client="Kodi", Device="%s", DeviceId="%s", Version="%s"' % (deviceName, deviceId, version)) + header = { 'Content-type': 'application/json', diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 29cf73a4..b528784a 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -57,7 +57,7 @@ class InitialSetup(object): if server['Id'] == settings('serverId'): server_address = self.connectmanager.get_address(server) self._set_server(server_address, server) - self._set_user(server['UserId'], server['AccessToken']) + #self._set_user(server['UserId'], server['AccessToken']) break return diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 2d68bba1..7390e597 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -159,6 +159,7 @@ class UserClient(threading.Thread): self._load_user() except Warning: log.info("token is invalid") + self._reset_client() else: log.info("current user: %s", self.get_username()) log.info("current userid: %s", self.get_userid()) @@ -176,7 +177,7 @@ class UserClient(threading.Thread): user_found = user break try: - user = self.connectmanager.login_manual(server, user_found) + user = connectmanager.ConnectManager().login_manual(server, user_found) except RuntimeError: window('emby_serverStatus', value="stop") self._auth = False @@ -219,17 +220,17 @@ class UserClient(threading.Thread): doutils.setToken(token) doutils.setSSL(self.get_ssl()) - # Start downloadutils.py session - doutils.startSession() - - # Set _user and _server - self._set_user_server() # verify user access try: self._set_access() except Warning: # We don't need to raise any exceptions pass + # Start downloadutils.py session + doutils.startSession() + # Set _user and _server + self._set_user_server() + def _reset_client(self): log.info("reset UserClient authentication") @@ -245,7 +246,6 @@ class UserClient(threading.Thread): def run(self): monitor = xbmc.Monitor() - self.connectmanager = connectmanager.ConnectManager() log.warn("----===## Starting UserClient ##===----")