Fix multi-server support

This commit is contained in:
angelblue05 2019-01-25 07:02:27 -06:00
parent caa758c3ec
commit 98ffa9b503
2 changed files with 12 additions and 4 deletions

View File

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

View File

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