From 98ffa9b503a3b97744e228964b01e6fac69f5c67 Mon Sep 17 00:00:00 2001
From: angelblue05 <angelblue.dev@gmail.com>
Date: Fri, 25 Jan 2019 07:02:27 -0600
Subject: [PATCH] Fix multi-server support

---
 resources/lib/emby/__init__.py | 14 +++++++++++---
 resources/lib/player.py        |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/resources/lib/emby/__init__.py b/resources/lib/emby/__init__.py
index fc478bd2..cc9f4775 100644
--- a/resources/lib/emby/__init__.py
+++ b/resources/lib/emby/__init__.py
@@ -40,11 +40,16 @@ def ensure_client():
 
 class Emby(object):
 
-    ''' This is your Embyclient, you can create more than one. The server_id is only a temporary thing.
+    ''' This is your Embyclient, you can create more than one. The server_id is only a temporary thing
+        to communicate with the EmbyClient().
+
         from emby import Emby
 
-        default_client = Emby()['config/app']
-        another_client = Emby('123456')['config/app']
+        Emby('123456')['config/app']
+
+        # Permanent client reference
+        client = Emby('123456').get_client()
+        client['config/app']
     '''
 
     # Borg - multiple instances, shared state
@@ -57,6 +62,9 @@ class Emby(object):
         self.__dict__ = self._shared_state
         self.server_id = server_id or "default"
 
+    def get_client(self):
+        return self.client[self.server_id]
+
     @classmethod
     def set_loghandler(cls, func=loghandler, level=logging.INFO):
 
diff --git a/resources/lib/player.py b/resources/lib/player.py
index c94616a2..2f522008 100644
--- a/resources/lib/player.py
+++ b/resources/lib/player.py
@@ -148,7 +148,7 @@ class Player(xbmc.Player):
             'CurrentPosition': item.get('CurrentPosition') or int(seektime),
             'Muted': muted,
             'Volume': volume,
-            'Server': Emby(item['ServerId']),
+            'Server': Emby(item['ServerId']).get_client(),
             'Paused': False
         })