Fix casting

This commit is contained in:
Matt 2021-01-23 13:35:21 -05:00
parent 54270b2ebd
commit 9d059a94d7
1 changed files with 19 additions and 0 deletions

View File

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