mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
Move api_client details to context.py
This commit is contained in:
parent
b2aa57aafa
commit
203fb81f58
2 changed files with 13 additions and 16 deletions
|
@ -52,6 +52,19 @@ class Context(object):
|
|||
self.media = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||
item_id = None
|
||||
|
||||
addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/data.json")
|
||||
with open(addon_data, 'rb') as infile:
|
||||
data = json.load(infile)
|
||||
|
||||
try:
|
||||
server_data = data['Servers'][0]
|
||||
self.api_client.config.data['auth.server'] = server_data.get('address')
|
||||
self.api_client.config.data['auth.server-name'] = server_data.get('Name')
|
||||
self.api_client.config.data['auth.user_id'] = server_data.get('UserId')
|
||||
self.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))
|
||||
|
||||
if self.server_id or item_id:
|
||||
self.item = self.api_client.get_item(item_id)
|
||||
else:
|
||||
|
|
|
@ -3,10 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
|
||||
#################################################################################################
|
||||
|
||||
import json
|
||||
|
||||
from helper import LazyLogger
|
||||
from kodi_six.xbmc import translatePath
|
||||
|
||||
from . import api
|
||||
from .configuration import Config
|
||||
|
@ -45,19 +42,6 @@ class JellyfinClient(object):
|
|||
self.callback_ws = callback
|
||||
self.callback = callback
|
||||
|
||||
addon_data = translatePath("special://profile/addon_data/plugin.video.jellyfin/data.json")
|
||||
with open(addon_data, 'rb') as infile:
|
||||
data = json.load(infile)
|
||||
|
||||
try:
|
||||
server_data = data['Servers'][0]
|
||||
self.jellyfin.config.data['auth.server'] = server_data.get('address')
|
||||
self.jellyfin.config.data['auth.server-name'] = server_data.get('Name')
|
||||
self.jellyfin.config.data['auth.user_id'] = server_data.get('UserId')
|
||||
self.jellyfin.config.data['auth.token'] = server_data.get('AccessToken')
|
||||
except Exception as e:
|
||||
LOG.warning('Addon appears to not be configured yet: {}'.format(e))
|
||||
|
||||
def set_credentials(self, credentials=None):
|
||||
self.auth.credentials.set_credentials(credentials or {})
|
||||
|
||||
|
|
Loading…
Reference in a new issue