From 9d059a94d77513787500e70a3cad318d62d988d6 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 23 Jan 2021 13:35:21 -0500 Subject: [PATCH] Fix casting --- jellyfin_kodi/objects/actions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 6ca92f24..483261bf 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -13,6 +13,7 @@ import database from helper import translate, playutils, api, window, settings, dialog from dialogs import resume from helper import LazyLogger +from jellyfin import Jellyfin from .obj import Objects @@ -28,8 +29,26 @@ class Actions(object): def __init__(self, server_id=None, api_client=None): self.server_id = server_id or None + if not api_client: + LOG.debug('No api client provided, attempting to use config file') + jellyfin_client = Jellyfin(server_id).get_client() + api_client = jellyfin_client.jellyfin + addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/data.json") + try: + with open(addon_data, 'rb') as infile: + data = json.load(infile) + + server_data = data['Servers'][0] + api_client.config.data['auth.server'] = server_data.get('address') + api_client.config.data['auth.server-name'] = server_data.get('Name') + api_client.config.data['auth.user_id'] = server_data.get('UserId') + api_client.config.data['auth.token'] = server_data.get('AccessToken') + except Exception as e: + LOG.warning('Addon appears to not be configured yet: {}'.format(e)) + self.api_client = api_client self.server = self.api_client.config.data['auth.server'] + self.stack = [] def get_playlist(self, item):