mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Cleanup __shortcuts__ in client.py and associated code (#66)
* client.py - remove "connected" * client.py - remove "config" & configuration.py - removed shortcuts and get/set item functions * client.py - remove "auth" & connection_manager.py - remove __shortcuts__ & __getitem__ * client.py - remove "auth" & connection_manager.py - remove __shortcuts__ & __getitem__ * client.py - remove "callback" * client.py - remove "websocket" and __getitem__ & ws_client.py - remove __shortcuts__ * Fix rebase mess-up
This commit is contained in:
parent
138451d516
commit
4049023559
19 changed files with 134 additions and 185 deletions
|
@ -81,9 +81,9 @@ class Connect(object):
|
|||
''' Get Jellyfin client.
|
||||
'''
|
||||
client = Jellyfin(server_id)
|
||||
client['config/app']("Kodi", self.info['Version'], self.info['DeviceName'], self.info['DeviceId'])
|
||||
client['config']['http.user_agent'] = "Jellyfin-Kodi/%s" % self.info['Version']
|
||||
client['config']['auth.ssl'] = self.get_ssl()
|
||||
client.config.app("Kodi", self.info['Version'], self.info['DeviceName'], self.info['DeviceId'])
|
||||
client.config.data['http.user_agent'] = "Jellyfin-Kodi/%s" % self.info['Version']
|
||||
client.config.data['auth.ssl'] = self.get_ssl()
|
||||
|
||||
return client
|
||||
|
||||
|
@ -94,7 +94,7 @@ class Connect(object):
|
|||
self.connect_manager = client.auth
|
||||
|
||||
if server_id is None:
|
||||
client['config']['app.default'] = True
|
||||
client.config.data['app.default'] = True
|
||||
|
||||
try:
|
||||
state = client.authenticate(credentials or {}, options or {})
|
||||
|
@ -107,8 +107,8 @@ class Connect(object):
|
|||
client.callback = event
|
||||
self.get_user(client)
|
||||
|
||||
settings('serverName', client['config/auth.server-name'])
|
||||
settings('server', client['config/auth.server'])
|
||||
settings('serverName', client.config.data['auth.server-name'])
|
||||
settings('server', client.config.data['auth.server'])
|
||||
|
||||
event('ServerOnline', {'ServerId': server_id})
|
||||
event('LoadServer', {'ServerId': server_id})
|
||||
|
@ -152,7 +152,9 @@ class Connect(object):
|
|||
settings('username', self.user['Name'])
|
||||
|
||||
if 'PrimaryImageTag' in self.user:
|
||||
window('JellyfinUserImage', api.API(self.user, client['auth/server-address']).get_user_artwork(self.user['Id']))
|
||||
server_data = client.auth.get_server_info(client.auth.server_id)
|
||||
server_address = client.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
window('JellyfinUserImage', api.API(self.user, server_address).get_user_artwork(self.user['Id']))
|
||||
|
||||
def select_servers(self, state=None):
|
||||
|
||||
|
@ -213,8 +215,9 @@ class Connect(object):
|
|||
|
||||
def login(self):
|
||||
|
||||
users = self.connect_manager['public-users']
|
||||
server = self.connect_manager['server-address']
|
||||
users = self.connect_manager.get_public_users()
|
||||
server_data = self.connect_manager.get_server_info(self.connect_manager.server_id)
|
||||
server = self.connect_manager.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
|
||||
if not users:
|
||||
try:
|
||||
|
@ -236,7 +239,7 @@ class Connect(object):
|
|||
return self.login_manual(username)
|
||||
except RuntimeError: pass
|
||||
else:
|
||||
return self.connect_manager['login'](server, username)
|
||||
return self.connect_manager.login(server, username)
|
||||
|
||||
elif dialog.is_manual_login():
|
||||
try:
|
||||
|
|
|
@ -118,9 +118,10 @@ class LoginManual(xbmcgui.WindowXMLDialog):
|
|||
|
||||
def _login(self, username, password):
|
||||
|
||||
mode = self.connect_manager['server-mode']
|
||||
server = self.connect_manager['server-address']
|
||||
result = self.connect_manager['login'](server, username, password)
|
||||
mode = self.connect_manager.get_server_info(self.connect_manager.server_id)['LastConnectionMode']
|
||||
server_data = self.connect_manager.get_server_info(self.connect_manager.server_id)
|
||||
server = self.connect_manager.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
result = self.connect_manager.login(server, username, password)
|
||||
|
||||
if not result:
|
||||
self._error(ERROR['Invalid'], _('invalid_auth'))
|
||||
|
|
|
@ -116,7 +116,7 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
|
|||
self.message_box.setVisibleCondition('true')
|
||||
self.busy.setVisibleCondition('true')
|
||||
|
||||
result = self.connect_manager['connect-to-server'](server)
|
||||
result = self.connect_manager.connect_to_server(server)
|
||||
|
||||
if result['State'] == CONNECTION_STATE['Unavailable']:
|
||||
self.busy.setVisibleCondition('false')
|
||||
|
|
|
@ -118,7 +118,7 @@ class ServerManual(xbmcgui.WindowXMLDialog):
|
|||
|
||||
server_address = "%s:%s" % (server, port) if port else server
|
||||
self._message("%s %s..." % (_(30610), server_address))
|
||||
result = self.connect_manager['manual-server'](server_address)
|
||||
result = self.connect_manager.connect_to_address(server_address)
|
||||
|
||||
if result['State'] == CONNECTION_STATE['Unavailable']:
|
||||
self._message(_(30609))
|
||||
|
|
|
@ -45,11 +45,11 @@ class Jellyfin(object):
|
|||
|
||||
from jellyfin import Jellyfin
|
||||
|
||||
Jellyfin('123456')['config/app']
|
||||
Jellyfin('123456').config.data['app']
|
||||
|
||||
# Permanent client reference
|
||||
client = Jellyfin('123456').get_client()
|
||||
client['config/app']
|
||||
client.config.data['app']
|
||||
'''
|
||||
|
||||
# Borg - multiple instances, shared state
|
||||
|
|
|
@ -55,7 +55,7 @@ class JellyfinClient(object):
|
|||
|
||||
LOG.info("User is authenticated.")
|
||||
self.logged_in = True
|
||||
self.callback("ServerOnline", {'Id': self['auth/server-id']})
|
||||
self.callback("ServerOnline", {'Id': self.auth.server_id})
|
||||
|
||||
state['Credentials'] = self.get_credentials()
|
||||
|
||||
|
@ -81,23 +81,3 @@ class JellyfinClient(object):
|
|||
|
||||
self.wsc.stop_client()
|
||||
self.http.stop_session()
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key.startswith('config'):
|
||||
return self.config[key.replace('config/', "", 1)] if "/" in key else self.config
|
||||
|
||||
elif key.startswith('websocket'):
|
||||
return self.wsc.__shortcuts__(key.replace('websocket/', "", 1))
|
||||
|
||||
elif key.startswith('callback'):
|
||||
return self.callback_ws if 'ws' in key else self.callback
|
||||
|
||||
elif key.startswith('auth'):
|
||||
return self.auth.__shortcuts__(key.replace('auth/', "", 1))
|
||||
|
||||
elif key == 'connected':
|
||||
return self.logged_in
|
||||
|
||||
return
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
def jellyfin_url(client, handler):
|
||||
return "%s/emby/%s" % (client.config['auth.server'], handler)
|
||||
return "%s/emby/%s" % (client.config.data['auth.server'], handler)
|
||||
|
||||
|
||||
def basic_info():
|
||||
|
|
|
@ -25,27 +25,6 @@ class Config(object):
|
|||
self.data = {}
|
||||
self.http()
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "auth":
|
||||
return self.auth
|
||||
elif key == "app":
|
||||
return self.app
|
||||
elif key == "http":
|
||||
return self.http
|
||||
elif key == "data":
|
||||
return self
|
||||
|
||||
return
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
return self.data.get(key, self.__shortcuts__(key))
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.data[key] = value
|
||||
|
||||
def app(self, name, version, device_name, device_id, capabilities=None, device_pixel_ratio=None):
|
||||
LOG.info("Begin app constructor.")
|
||||
|
||||
|
|
|
@ -57,48 +57,6 @@ class ConnectionManager(object):
|
|||
|
||||
self.http = HTTP(client)
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "clear":
|
||||
return self.clear_data
|
||||
elif key == "servers":
|
||||
return self.get_available_servers()
|
||||
elif key in ("reconnect", "refresh"):
|
||||
return self.connect
|
||||
elif key == "login":
|
||||
return self.login
|
||||
elif key == "server":
|
||||
return self.get_server_info(self.server_id)
|
||||
elif key == "server-id":
|
||||
return self.server_id
|
||||
elif key == "server-version":
|
||||
return self.server_version
|
||||
elif key == "user-id":
|
||||
return self.jellyfin_user_id()
|
||||
elif key == "public-users":
|
||||
return self.get_public_users()
|
||||
elif key == "token":
|
||||
return self.jellyfin_token()
|
||||
elif key == "manual-server":
|
||||
return self.connect_to_address
|
||||
elif key == "connect-to-server":
|
||||
return self.connect_to_server
|
||||
elif key == "server-address":
|
||||
server = self.get_server_info(self.server_id)
|
||||
return get_server_address(server, server['LastConnectionMode'])
|
||||
elif key == "revoke-token":
|
||||
return self.revoke_token()
|
||||
elif key == "server-mode":
|
||||
server = self.get_server_info(self.server_id)
|
||||
return server['LastConnectionMode']
|
||||
|
||||
return
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
return self.__shortcuts__(key)
|
||||
|
||||
def clear_data(self):
|
||||
|
||||
LOG.info("connection manager clearing data")
|
||||
|
@ -117,7 +75,7 @@ class ConnectionManager(object):
|
|||
self['server']['AccessToken'] = None
|
||||
self.credentials.get_credentials(self.credentials.get_credentials())
|
||||
|
||||
self.config['auth.token'] = None
|
||||
self.config.data['auth.token'] = None
|
||||
|
||||
def get_available_servers(self):
|
||||
|
||||
|
@ -151,7 +109,7 @@ class ConnectionManager(object):
|
|||
|
||||
if not server:
|
||||
raise AttributeError("server cannot be empty")
|
||||
|
||||
|
||||
try:
|
||||
request = {
|
||||
'type': "POST",
|
||||
|
@ -219,6 +177,14 @@ class ConnectionManager(object):
|
|||
LOG.info("beginning connection tests")
|
||||
return self._test_next_connection_mode(tests, 0, server, options)
|
||||
|
||||
def get_server_address(self, server, mode): #TODO: De-duplicated (Duplicated from above when getting rid of shortcuts)
|
||||
|
||||
modes = {
|
||||
CONNECTION_MODE['Local']: server.get('LocalAddress'),
|
||||
CONNECTION_MODE['Manual']: server.get('ManualAddress')
|
||||
}
|
||||
return modes.get(mode) or server.get('ManualAddress', server.get('LocalAddress'))
|
||||
|
||||
def connect(self, options={}):
|
||||
|
||||
LOG.info("Begin connect")
|
||||
|
@ -261,7 +227,7 @@ class ConnectionManager(object):
|
|||
raise
|
||||
|
||||
def _add_app_info(self):
|
||||
return "%s/%s" % (self.config['app.name'], self.config['app.version'])
|
||||
return "%s/%s" % (self.config.data['app.name'], self.config.data['app.version'])
|
||||
|
||||
def _get_headers(self, request):
|
||||
|
||||
|
@ -526,15 +492,15 @@ class ConnectionManager(object):
|
|||
|
||||
if options.get('enableAutoLogin') == False:
|
||||
|
||||
self.config['auth.user_id'] = server.pop('UserId', None)
|
||||
self.config['auth.token'] = server.pop('AccessToken', None)
|
||||
self.config.data['auth.user_id'] = server.pop('UserId', None)
|
||||
self.config.data['auth.token'] = server.pop('AccessToken', None)
|
||||
|
||||
elif verify_authentication and server.get('AccessToken'):
|
||||
|
||||
if self._validate_authentication(server, connection_mode, options) is not False:
|
||||
|
||||
self.config['auth.user_id'] = server['UserId']
|
||||
self.config['auth.token'] = server['AccessToken']
|
||||
self.config.data['auth.user_id'] = server['UserId']
|
||||
self.config.data['auth.token'] = server['AccessToken']
|
||||
return self._after_connect_validated(server, credentials, system_info, connection_mode, False, options)
|
||||
|
||||
return self._resolve_failure()
|
||||
|
@ -551,10 +517,10 @@ class ConnectionManager(object):
|
|||
self.server_id = server['Id']
|
||||
|
||||
# Update configs
|
||||
self.config['auth.server'] = get_server_address(server, connection_mode)
|
||||
self.config['auth.server-name'] = server['Name']
|
||||
self.config['auth.server=id'] = server['Id']
|
||||
self.config['auth.ssl'] = options.get('ssl', self.config['auth.ssl'])
|
||||
self.config.data['auth.server'] = get_server_address(server, connection_mode)
|
||||
self.config.data['auth.server-name'] = server['Name']
|
||||
self.config.data['auth.server=id'] = server['Id']
|
||||
self.config.data['auth.ssl'] = options.get('ssl', self.config.data['auth.ssl'])
|
||||
|
||||
result = {
|
||||
'Servers': [server]
|
||||
|
@ -602,8 +568,8 @@ class ConnectionManager(object):
|
|||
|
||||
credentials = self.credentials.get_credentials()
|
||||
|
||||
self.config['auth.user_id'] = result['User']['Id']
|
||||
self.config['auth.token'] = result['AccessToken']
|
||||
self.config.data['auth.user_id'] = result['User']['Id']
|
||||
self.config.data['auth.token'] = result['AccessToken']
|
||||
|
||||
for server in credentials['Servers']:
|
||||
if server['Id'] == result['ServerId']:
|
||||
|
|
|
@ -24,13 +24,13 @@ class HTTP(object):
|
|||
def __init__(self, client):
|
||||
|
||||
self.client = client
|
||||
self.config = client['config']
|
||||
self.config = client.config
|
||||
|
||||
def start_session(self):
|
||||
|
||||
self.session = requests.Session()
|
||||
|
||||
max_retries = self.config['http.max_retries']
|
||||
max_retries = self.config.data['http.max_retries']
|
||||
self.session.mount("http://", requests.adapters.HTTPAdapter(max_retries=max_retries))
|
||||
self.session.mount("https://", requests.adapters.HTTPAdapter(max_retries=max_retries))
|
||||
|
||||
|
@ -48,14 +48,14 @@ class HTTP(object):
|
|||
def _replace_user_info(self, string):
|
||||
|
||||
if '{server}' in string:
|
||||
if self.config['auth.server']:
|
||||
string = string.decode('utf-8').replace("{server}", self.config['auth.server'])
|
||||
if self.config.data['auth.server']:
|
||||
string = string.decode('utf-8').replace("{server}", self.config.data['auth.server'])
|
||||
else:
|
||||
raise Exception("Server address not set.")
|
||||
|
||||
if '{UserId}'in string:
|
||||
if self.config['auth.user_id']:
|
||||
string = string.decode('utf-8').replace("{UserId}", self.config['auth.user_id'])
|
||||
if self.config.data['auth.user_id']:
|
||||
string = string.decode('utf-8').replace("{UserId}", self.config.data['auth.user_id'])
|
||||
else:
|
||||
raise Exception("UserId is not set.")
|
||||
|
||||
|
@ -100,7 +100,7 @@ class HTTP(object):
|
|||
continue
|
||||
|
||||
LOG.error(error)
|
||||
self.client['callback']("ServerUnreachable", {'ServerId': self.config['auth.server-id']})
|
||||
self.client.callback("ServerUnreachable", {'ServerId': self.config.data['auth.server-id']})
|
||||
|
||||
raise HTTPException("ServerUnreachable", error)
|
||||
|
||||
|
@ -122,12 +122,12 @@ class HTTP(object):
|
|||
if r.status_code == 401:
|
||||
|
||||
if 'X-Application-Error-Code' in r.headers:
|
||||
self.client['callback']("AccessRestricted", {'ServerId': self.config['auth.server-id']})
|
||||
self.client.callback("AccessRestricted", {'ServerId': self.config.data['auth.server-id']})
|
||||
|
||||
raise HTTPException("AccessRestricted", error)
|
||||
else:
|
||||
self.client['callback']("Unauthorized", {'ServerId': self.config['auth.server-id']})
|
||||
self.client['auth/revoke-token']
|
||||
self.client.callback("Unauthorized", {'ServerId': self.config.data['auth.server-id']})
|
||||
self.client.auth.revoke_token()
|
||||
|
||||
raise HTTPException("Unauthorized", error)
|
||||
|
||||
|
@ -147,14 +147,14 @@ class HTTP(object):
|
|||
raise HTTPException(r.status_code, error)
|
||||
|
||||
except requests.exceptions.MissingSchema as error:
|
||||
raise HTTPException("MissingSchema", {'Id': self.config['auth.server']})
|
||||
raise HTTPException("MissingSchema", {'Id': self.config.data['auth.server']})
|
||||
|
||||
except Exception as error:
|
||||
raise
|
||||
|
||||
else:
|
||||
try:
|
||||
self.config['server-time'] = r.headers['Date']
|
||||
self.config.data['server-time'] = r.headers['Date']
|
||||
elapsed = int(r.elapsed.total_seconds() * 1000)
|
||||
response = r.json()
|
||||
LOG.debug("---<[ http ][%s ms]", elapsed)
|
||||
|
@ -167,11 +167,11 @@ class HTTP(object):
|
|||
def _request(self, data):
|
||||
|
||||
if 'url' not in data:
|
||||
data['url'] = "%s/emby/%s" % (self.config['auth.server'], data.pop('handler', ""))
|
||||
data['url'] = "%s/emby/%s" % (self.config.data['auth.server'], data.pop('handler', ""))
|
||||
|
||||
self._get_header(data)
|
||||
data['timeout'] = data.get('timeout') or self.config['http.timeout']
|
||||
data['verify'] = data.get('verify') or self.config['auth.ssl'] or False
|
||||
data['timeout'] = data.get('timeout') or self.config.data['http.timeout']
|
||||
data['verify'] = data.get('verify') or self.config.data['auth.ssl'] or False
|
||||
data['url'] = self._replace_user_info(data['url'])
|
||||
self._process_params(data.get('params') or {})
|
||||
self._process_params(data.get('json') or {})
|
||||
|
@ -198,7 +198,7 @@ class HTTP(object):
|
|||
'Content-type': "application/json",
|
||||
'Accept-Charset': "UTF-8,*",
|
||||
'Accept-encoding': "gzip",
|
||||
'User-Agent': self.config['http.user_agent'] or "%s/%s" % (self.config['app.name'], self.config['app.version'])
|
||||
'User-Agent': self.config.data['http.user_agent'] or "%s/%s" % (self.config.data['app.name'], self.config.data['app.version'])
|
||||
})
|
||||
|
||||
if 'x-emby-authorization' not in data['headers']:
|
||||
|
@ -209,17 +209,17 @@ class HTTP(object):
|
|||
def _authorization(self, data):
|
||||
|
||||
auth = "MediaBrowser "
|
||||
auth += "Client=%s, " % self.config['app.name'].encode('utf-8')
|
||||
auth += "Device=%s, " % self.config['app.device_name'].encode('utf-8')
|
||||
auth += "DeviceId=%s, " % self.config['app.device_id'].encode('utf-8')
|
||||
auth += "Version=%s" % self.config['app.version'].encode('utf-8')
|
||||
auth += "Client=%s, " % self.config.data['app.name'].encode('utf-8')
|
||||
auth += "Device=%s, " % self.config.data['app.device_name'].encode('utf-8')
|
||||
auth += "DeviceId=%s, " % self.config.data['app.device_id'].encode('utf-8')
|
||||
auth += "Version=%s" % self.config.data['app.version'].encode('utf-8')
|
||||
|
||||
data['headers'].update({'x-emby-authorization': auth})
|
||||
|
||||
if self.config['auth.token'] and self.config['auth.user_id']:
|
||||
if self.config.data.get('auth.token') and self.config.data.get('auth.user_id'):
|
||||
|
||||
auth += ', UserId=%s' % self.config['auth.user_id'].encode('utf-8')
|
||||
data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config['auth.token'].encode('utf-8')})
|
||||
auth += ', UserId=%s' % self.config.data['auth.user_id'].encode('utf-8')
|
||||
data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config.data['auth.token'].encode('utf-8')})
|
||||
|
||||
return data
|
||||
|
||||
|
|
|
@ -30,16 +30,6 @@ class WSClient(threading.Thread):
|
|||
self.client = client
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "send":
|
||||
return self.send
|
||||
elif key == "stop":
|
||||
return self.stop_client()
|
||||
|
||||
return
|
||||
|
||||
def send(self, message, data=""):
|
||||
|
||||
if self.wsc is None:
|
||||
|
@ -50,9 +40,9 @@ class WSClient(threading.Thread):
|
|||
def run(self):
|
||||
|
||||
monitor = xbmc.Monitor()
|
||||
token = self.client['config/auth.token']
|
||||
device_id = self.client['config/app.device_id']
|
||||
server = self.client['config/auth.server']
|
||||
token = self.client.config.data['auth.token']
|
||||
device_id = self.client.config.data['app.device_id']
|
||||
server = self.client.config.data['auth.server']
|
||||
server = server.replace('https', "wss") if server.startswith('https') else server.replace('http', "ws")
|
||||
wsc_url = "%s/embywebsocket?api_key=%s&device_id=%s" % (server, token, device_id)
|
||||
|
||||
|
@ -88,10 +78,10 @@ class WSClient(threading.Thread):
|
|||
|
||||
return
|
||||
|
||||
if not self.client['config/app.default']:
|
||||
data['ServerId'] = self.client['auth/server-id']
|
||||
if not self.client.config.data['app.default']:
|
||||
data['ServerId'] = self.client.auth.server_id
|
||||
|
||||
self.client['callback_ws'](message['MessageType'], data)
|
||||
self.client.callback(message['MessageType'], data)
|
||||
|
||||
def stop_client(self):
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ class Library(threading.Thread):
|
|||
def save_last_sync(self):
|
||||
|
||||
try:
|
||||
time_now = datetime.strptime(self.server['config/server-time'].split(', ', 1)[1], '%d %b %Y %H:%M:%S GMT') - timedelta(minutes=2)
|
||||
time_now = datetime.strptime(self.server.config.data['server-time'].split(', ', 1)[1], '%d %b %Y %H:%M:%S GMT') - timedelta(minutes=2)
|
||||
except Exception as error:
|
||||
|
||||
LOG.exception(error)
|
||||
|
|
|
@ -144,8 +144,9 @@ class Monitor(xbmc.Monitor):
|
|||
self.void_responder(data, item)
|
||||
|
||||
elif method == 'GetServerAddress':
|
||||
|
||||
server_address = server['auth/server-address']
|
||||
|
||||
server_data = server.auth.get_server_info(server.auth.server_id)
|
||||
server_address = server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
self.void_responder(data, server_address)
|
||||
|
||||
elif method == 'GetPlaybackInfo':
|
||||
|
@ -160,7 +161,7 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
elif method == 'GetToken':
|
||||
|
||||
token = server['auth/token']
|
||||
token = server.auth.jellyfin_token()
|
||||
self.void_responder(data, token)
|
||||
|
||||
elif method == 'GetSession':
|
||||
|
@ -235,7 +236,7 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
elif method == 'PlayPlaylist':
|
||||
|
||||
server.jellyfin.post_session(server['config/app.session'], "Playing", {
|
||||
server.jellyfin.post_session(server.config.data['app.session'], "Playing", {
|
||||
'PlayCommand': "PlayNow",
|
||||
'ItemIds': data['Id'],
|
||||
'StartPositionTicks': 0
|
||||
|
@ -262,7 +263,7 @@ class Monitor(xbmc.Monitor):
|
|||
self.server_instance(data['ServerId'])
|
||||
|
||||
elif method == 'AddUser':
|
||||
server.jellyfin.session_add_user(server['config/app.session'], data['Id'], data['Add'])
|
||||
server.jellyfin.session_add_user(server.config.data['app.session'], data['Id'], data['Add'])
|
||||
self.additional_users(server)
|
||||
|
||||
elif method == 'Player.OnPlay':
|
||||
|
@ -292,12 +293,12 @@ class Monitor(xbmc.Monitor):
|
|||
for user in all_users:
|
||||
|
||||
if user['Name'].lower() in additional.decode('utf-8').lower():
|
||||
server.jellyfin.session_add_user(server['config/app.session'], user['Id'], True)
|
||||
server.jellyfin.session_add_user(server.config.data['app.session'], user['Id'], True)
|
||||
|
||||
self.additional_users(server)
|
||||
|
||||
def post_capabilities(self, server):
|
||||
LOG.info("--[ post capabilities/%s ]", server['auth/server-id'])
|
||||
LOG.info("--[ post capabilities/%s ]", server.auth.server_id)
|
||||
|
||||
server.jellyfin.post_capabilities({
|
||||
'PlayableMediaTypes': "Audio,Video",
|
||||
|
@ -314,9 +315,8 @@ class Monitor(xbmc.Monitor):
|
|||
"Play,Playstate,PlayNext,PlayMediaSource"
|
||||
),
|
||||
})
|
||||
|
||||
session = server.jellyfin.get_device(self.device_id)
|
||||
server['config']['app.session'] = session[0]['Id']
|
||||
server.config.data['app.session'] = session[0]['Id']
|
||||
|
||||
def additional_users(self, server):
|
||||
|
||||
|
@ -335,7 +335,7 @@ class Monitor(xbmc.Monitor):
|
|||
for index, user in enumerate(session[0]['AdditionalUsers']):
|
||||
|
||||
info = server.jellyfin.get_user(user['UserId'])
|
||||
image = api.API(info, server['config/auth.server']).get_user_artwork(user['UserId'])
|
||||
image = api.API(info, server.config.data['auth.server']).get_user_artwork(user['UserId'])
|
||||
window('JellyfinAdditionalUserImage.%s' % index, image)
|
||||
window('JellyfinAdditionalUserPosition.%s' % user['UserId'], str(index))
|
||||
|
||||
|
|
|
@ -54,7 +54,9 @@ class Movies(KodiDb):
|
|||
''' If item does not exist, entry will be added.
|
||||
If item exists, entry will be updated.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Movie')
|
||||
update = True
|
||||
|
||||
|
@ -213,7 +215,9 @@ class Movies(KodiDb):
|
|||
Process movies inside boxset.
|
||||
Process removals from boxset.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Boxset')
|
||||
|
||||
obj['Overview'] = API.get_overview(obj['Overview'])
|
||||
|
@ -291,7 +295,9 @@ class Movies(KodiDb):
|
|||
''' This updates: Favorite, LastPlayedDate, Playcount, PlaybackPositionTicks
|
||||
Poster with progress bar
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'MovieUserData')
|
||||
|
||||
try:
|
||||
|
|
|
@ -56,7 +56,9 @@ class Music(KodiDb):
|
|||
''' If item does not exist, entry will be added.
|
||||
If item exists, entry will be updated.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Artist')
|
||||
update = True
|
||||
|
||||
|
@ -125,7 +127,9 @@ class Music(KodiDb):
|
|||
|
||||
''' Update object to kodi.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Album')
|
||||
update = True
|
||||
|
||||
|
@ -234,7 +238,9 @@ class Music(KodiDb):
|
|||
|
||||
''' Update object to kodi.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Song')
|
||||
update = True
|
||||
|
||||
|
@ -352,7 +358,9 @@ class Music(KodiDb):
|
|||
obj['Path'] = obj['Path'].replace(obj['Filename'], "")
|
||||
|
||||
else:
|
||||
obj['Path'] = "%s/emby/Audio/%s/" % (self.server['auth/server-address'], obj['Id'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
obj['Path'] = "%s/emby/Audio/%s/" % (server_address, obj['Id'])
|
||||
obj['Filename'] = "stream.%s?static=true" % obj['Container']
|
||||
|
||||
def song_artist_discography(self, obj):
|
||||
|
@ -429,7 +437,9 @@ class Music(KodiDb):
|
|||
''' This updates: Favorite, LastPlayedDate, Playcount, PlaybackPositionTicks
|
||||
Poster with progress bar
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'SongUserData')
|
||||
|
||||
try:
|
||||
|
|
|
@ -55,7 +55,9 @@ class MusicVideos(KodiDb):
|
|||
If we don't get the track number from Jellyfin, see if we can infer it
|
||||
from the sortname attribute.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'MusicVideo')
|
||||
update = True
|
||||
|
||||
|
@ -192,7 +194,9 @@ class MusicVideos(KodiDb):
|
|||
''' This updates: Favorite, LastPlayedDate, Playcount, PlaybackPositionTicks
|
||||
Poster with progress bar
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'MusicVideoUserData')
|
||||
|
||||
try:
|
||||
|
|
|
@ -63,7 +63,9 @@ class TVShows(KodiDb):
|
|||
Process seasons.
|
||||
Apply series pooling.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Series')
|
||||
update = True
|
||||
|
||||
|
@ -230,7 +232,9 @@ class TVShows(KodiDb):
|
|||
|
||||
If the show is empty, try to remove it.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Season')
|
||||
|
||||
obj['ShowId'] = show_id
|
||||
|
@ -265,7 +269,9 @@ class TVShows(KodiDb):
|
|||
Create additional entry for widgets.
|
||||
This is only required for plugin/episode.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'Episode')
|
||||
update = True
|
||||
|
||||
|
@ -459,7 +465,9 @@ class TVShows(KodiDb):
|
|||
Make sure there's no other bookmarks created by widget.
|
||||
Create additional entry for widgets. This is only required for plugin/episode.
|
||||
'''
|
||||
API = api.API(item, self.server['auth/server-address'])
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(item, server_address)
|
||||
obj = self.objects.map(item, 'EpisodeUserData')
|
||||
|
||||
try:
|
||||
|
|
|
@ -252,8 +252,9 @@ class Player(xbmc.Player):
|
|||
return
|
||||
|
||||
break
|
||||
|
||||
API = api.API(next_item, item['Server']['auth/server-address'])
|
||||
server_data = item['Server'].auth.get_server_info(item['Server'].auth.server_id)
|
||||
server_address = item['Server'].auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
API = api.API(next_item, server_address)
|
||||
data = objects.map(next_item, "UpNext")
|
||||
artwork = API.get_all_artwork(objects.map(next_item, 'ArtworkParent'), True)
|
||||
data['art'] = {
|
||||
|
|
|
@ -856,15 +856,16 @@ class Views(object):
|
|||
|
||||
def window_artwork(self, prop, view_id):
|
||||
|
||||
if not self.server['connected']:
|
||||
if not self.server.logged_in:
|
||||
window('%s.artwork' % prop, clear=True)
|
||||
|
||||
elif self.server['connected'] and self.media_folders is not None:
|
||||
elif self.server.logged_in and self.media_folders is not None:
|
||||
for library in self.media_folders:
|
||||
|
||||
if library['Id'] == view_id and 'Primary' in library.get('ImageTags', {}):
|
||||
|
||||
artwork = api.API(None, self.server['auth/server-address']).get_artwork(view_id, 'Primary')
|
||||
server_data = self.server.auth.get_server_info(self.server.auth.server_id)
|
||||
server_address = self.server.auth.get_server_address(server_data, server_data['LastConnectionMode'])
|
||||
artwork = api.API(None, server_address).get_artwork(view_id, 'Primary')
|
||||
window('%s.artwork' % prop, artwork)
|
||||
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue