From 60db191efababbf5dac0c0d0df0763ab87f9341e Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 12 Sep 2018 22:51:28 -0500 Subject: [PATCH] Fix profile auth One device id per user. --- resources/lib/client.py | 7 ++++++- resources/lib/emby/client.py | 5 ++++- resources/lib/emby/core/connection_manager.py | 5 +++-- resources/lib/emby/core/http.py | 1 + resources/lib/entrypoint/service.py | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/resources/lib/client.py b/resources/lib/client.py index a69058a2..c86148ed 100644 --- a/resources/lib/client.py +++ b/resources/lib/client.py @@ -76,7 +76,12 @@ def get_device_id(reset=False): if client_id: return client_id - emby_guid = xbmc.translatePath('special://temp/emby_guid').decode('utf-8') + directory = xbmc.translatePath('special://special://profile/addon_data/plugin.video.emby/').decode('utf-8') + + if not xbmcvfs.exists(directory): + xbmcvfs.mkdir(directory) + + emby_guid = os.path.join(directory, "emby_guid") file_guid = xbmcvfs.File(emby_guid) client_id = file_guid.read() diff --git a/resources/lib/emby/client.py b/resources/lib/emby/client.py index 2209b069..f5a2847c 100644 --- a/resources/lib/emby/client.py +++ b/resources/lib/emby/client.py @@ -61,13 +61,16 @@ class EmbyClient(object): return state - def start(self, websocket=False): + def start(self, websocket=False, keep_alive=True): if not self.logged_in: raise ValueError("User is not authenticated.") self.http.start_session() + if keep_alive: + self.http.keep_alive = True + if websocket: self.start_wsc() diff --git a/resources/lib/emby/core/connection_manager.py b/resources/lib/emby/core/connection_manager.py index 1e105756..18e02e0b 100644 --- a/resources/lib/emby/core/connection_manager.py +++ b/resources/lib/emby/core/connection_manager.py @@ -461,7 +461,6 @@ class ConnectionManager(object): def _get_min_server_version(self, val=None): if val is not None: - LOG.info("hello?") self.min_server_version = val return self.min_server_version @@ -809,9 +808,11 @@ class ConnectionManager(object): } }) self._update_server_info(server, system_info) - except Exception: + except Exception as error: + server['UserId'] = None server['AccessToken'] = None + return False def _update_server_info(self, server, system_info): diff --git a/resources/lib/emby/core/http.py b/resources/lib/emby/core/http.py index b7c64800..64b15641 100644 --- a/resources/lib/emby/core/http.py +++ b/resources/lib/emby/core/http.py @@ -46,6 +46,7 @@ class HTTP(object): return try: + LOG.warn("Closing session %s", id(self.session)) self.session.close() except Exception as error: LOG.warn("The requests session could not be terminated: %s", error) diff --git a/resources/lib/entrypoint/service.py b/resources/lib/entrypoint/service.py index 34735fcf..fabd9b7d 100644 --- a/resources/lib/entrypoint/service.py +++ b/resources/lib/entrypoint/service.py @@ -398,7 +398,7 @@ class Service(xbmc.Monitor): "emby_initialScan", "emby_play", "emby_online", "emby.connected", "emby_should_stop", "emby.resume", - "emby.external", "emby.external_check" + "emby.external", "emby.external_check", "emby_deviceId" ] for prop in properties: window(prop, clear=True)