client.py - remove api

This commit is contained in:
TrueTechy 2019-09-04 03:58:31 +01:00
parent bf2b4e8c32
commit b7fa48ea84
12 changed files with 56 additions and 59 deletions

View file

@ -148,7 +148,7 @@ class Connect(object):
''' Save user info. ''' Save user info.
''' '''
self.user = client['api'].get_user() self.user = client.jellyfin.get_user()
settings('username', self.user['Name']) settings('username', self.user['Name'])
if 'PrimaryImageTag' in self.user: if 'PrimaryImageTag' in self.user:

View file

@ -228,7 +228,7 @@ class FullSync(object):
return return
library = self.server['api'].get_item(library_id.replace('Mixed:', "")) library = self.server.jellyfin.get_item(library_id.replace('Mixed:', ""))
if library_id.startswith('Mixed:'): if library_id.startswith('Mixed:'):
for mixed in ('movies', 'tvshows'): for mixed in ('movies', 'tvshows'):

View file

@ -136,7 +136,7 @@ def library_check():
view = None view = None
if view is None: if view is None:
ancestors = self.server['api'].get_ancestors(item['Id']) ancestors = self.server.jellyfin.get_ancestors(item['Id'])
if not ancestors: if not ancestors:
if item['Type'] == 'MusicArtist': if item['Type'] == 'MusicArtist':

View file

@ -97,9 +97,6 @@ class JellyfinClient(object):
elif key.startswith('auth'): elif key.startswith('auth'):
return self.auth.__shortcuts__(key.replace('auth/', "", 1)) return self.auth.__shortcuts__(key.replace('auth/', "", 1))
elif key.startswith('api'):
return self.jellyfin
elif key == 'connected': elif key == 'connected':
return self.logged_in return self.logged_in

View file

@ -348,7 +348,7 @@ class Library(threading.Thread):
if settings('SyncInstallRunDone.bool'): if settings('SyncInstallRunDone.bool'):
if settings('kodiCompanion.bool'): if settings('kodiCompanion.bool'):
for plugin in self.server['api'].get_plugins(): for plugin in self.server.jellyfin.get_plugins():
if plugin['Name'] in ("Jellyfin.Kodi Sync Queue", "Kodi companion", "Kodi Sync Queue"): if plugin['Name'] in ("Jellyfin.Kodi Sync Queue", "Kodi companion", "Kodi Sync Queue"):
if not self.fast_sync(): if not self.fast_sync():
@ -400,7 +400,7 @@ class Library(threading.Thread):
""" """
for library in sync['Whitelist']: for library in sync['Whitelist']:
data = self.server['api'].get_date_modified(last_sync, library.replace('Mixed:', ""), "Series,Episode,BoxSet,Movie,MusicVideo,MusicArtist,MusicAlbum,Audio") data = self.server.jellyfin.get_date_modified(last_sync, library.replace('Mixed:', ""), "Series,Episode,BoxSet,Movie,MusicVideo,MusicArtist,MusicAlbum,Audio")
[self.updated_output[query['Type']].put(query) for query in data['Items']] [self.updated_output[query['Type']].put(query) for query in data['Items']]
""" """
try: try:
@ -409,7 +409,7 @@ class Library(threading.Thread):
removed = [] removed = []
for media in filters: for media in filters:
result = self.server['api'].get_sync_queue(last_sync, ",".join([x for x in filters if x != media])) result = self.server.jellyfin.get_sync_queue(last_sync, ",".join([x for x in filters if x != media]))
updated.extend(result['ItemsAdded']) updated.extend(result['ItemsAdded'])
updated.extend(result['ItemsUpdated']) updated.extend(result['ItemsUpdated'])
userdata.extend(result['UserDataChanged']) userdata.extend(result['UserDataChanged'])
@ -431,7 +431,7 @@ class Library(threading.Thread):
self.removed(removed) self.removed(removed)
""" """
result = self.server['api'].get_sync_queue(last_sync) result = self.server.jellyfin.get_sync_queue(last_sync)
self.userdata(result['UserDataChanged']) self.userdata(result['UserDataChanged'])
self.removed(result['ItemsRemoved']) self.removed(result['ItemsRemoved'])
@ -439,7 +439,7 @@ class Library(threading.Thread):
filters.extend(["tvshows", "boxsets", "musicvideos", "music"]) filters.extend(["tvshows", "boxsets", "musicvideos", "music"])
# Get only movies. # Get only movies.
result = self.server['api'].get_sync_queue(last_sync, ",".join(filters)) result = self.server.jellyfin.get_sync_queue(last_sync, ",".join(filters))
self.updated(result['ItemsAdded']) self.updated(result['ItemsAdded'])
self.updated(result['ItemsUpdated']) self.updated(result['ItemsUpdated'])
self.userdata(result['UserDataChanged']) self.userdata(result['UserDataChanged'])

View file

@ -125,22 +125,22 @@ class Monitor(xbmc.Monitor):
if method == 'GetItem': if method == 'GetItem':
item = server['api'].get_item(data['Id']) item = server.jellyfin.get_item(data['Id'])
self.void_responder(data, item) self.void_responder(data, item)
elif method == 'GetAdditionalParts': elif method == 'GetAdditionalParts':
item = server['api'].get_additional_parts(data['Id']) item = server.jellyfin.get_additional_parts(data['Id'])
self.void_responder(data, item) self.void_responder(data, item)
elif method == 'GetIntros': elif method == 'GetIntros':
item = server['api'].get_intros(data['Id']) item = server.jellyfin.get_intros(data['Id'])
self.void_responder(data, item) self.void_responder(data, item)
elif method == 'GetImages': elif method == 'GetImages':
item = server['api'].get_images(data['Id']) item = server.jellyfin.get_images(data['Id'])
self.void_responder(data, item) self.void_responder(data, item)
elif method == 'GetServerAddress': elif method == 'GetServerAddress':
@ -150,12 +150,12 @@ class Monitor(xbmc.Monitor):
elif method == 'GetPlaybackInfo': elif method == 'GetPlaybackInfo':
sources = server['api'].get_play_info(data['Id'], data['Profile']) sources = server.jellyfin.get_play_info(data['Id'], data['Profile'])
self.void_responder(data, sources) self.void_responder(data, sources)
elif method == 'GetLiveStream': elif method == 'GetLiveStream':
sources = server['api'].get_live_stream(data['Id'], data['PlaySessionId'], data['Token'], data['Profile']) sources = server.jellyfin.get_live_stream(data['Id'], data['PlaySessionId'], data['Token'], data['Profile'])
self.void_responder(data, sources) self.void_responder(data, sources)
elif method == 'GetToken': elif method == 'GetToken':
@ -165,31 +165,31 @@ class Monitor(xbmc.Monitor):
elif method == 'GetSession': elif method == 'GetSession':
session = server['api'].get_device(self.device_id) session = server.jellyfin.get_device(self.device_id)
self.void_responder(data, session) self.void_responder(data, session)
elif method == 'GetUsers': elif method == 'GetUsers':
users = server['api'].get_users() users = server.jellyfin.get_users()
self.void_responder(data, users) self.void_responder(data, users)
elif method == 'GetTranscodeOptions': elif method == 'GetTranscodeOptions':
result = server['api'].get_transcode_settings() result = server.jellyfin.get_transcode_settings()
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'GetThemes': elif method == 'GetThemes':
if data['Type'] == 'Video': if data['Type'] == 'Video':
theme = server['api'].get_items_theme_video(data['Id']) theme = server.jellyfin.get_items_theme_video(data['Id'])
else: else:
theme = server['api'].get_items_theme_song(data['Id']) theme = server.jellyfin.get_items_theme_song(data['Id'])
self.void_responder(data, theme) self.void_responder(data, theme)
elif method == 'GetTheme': elif method == 'GetTheme':
theme = server['api'].get_themes(data['Id']) theme = server.jellyfin.get_themes(data['Id'])
self.void_responder(data, theme) self.void_responder(data, theme)
elif method == 'Browse': elif method == 'Browse':
@ -201,41 +201,41 @@ class Monitor(xbmc.Monitor):
elif method == 'BrowseSeason': elif method == 'BrowseSeason':
result = server['api'].get_seasons(data['Id']) result = server.jellyfin.get_seasons(data['Id'])
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'LiveTV': elif method == 'LiveTV':
result = server['api'].get_channels() result = server.jellyfin.get_channels()
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'RecentlyAdded': elif method == 'RecentlyAdded':
result = server['api'].get_recently_added(data.get('Media'), data.get('Id'), data.get('Limit')) result = server.jellyfin.get_recently_added(data.get('Media'), data.get('Id'), data.get('Limit'))
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'Genres': elif method == 'Genres':
result = server['api'].get_genres(data.get('Id')) result = server.jellyfin.get_genres(data.get('Id'))
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'Recommended': elif method == 'Recommended':
result = server['api'].get_recommendation(data.get('Id'), data.get('Limit')) result = server.jellyfin.get_recommendation(data.get('Id'), data.get('Limit'))
self.void_responder(data, result) self.void_responder(data, result)
elif method == 'RefreshItem': elif method == 'RefreshItem':
server['api'].refresh_item(data['Id']) server.jellyfin.refresh_item(data['Id'])
elif method == 'FavoriteItem': elif method == 'FavoriteItem':
server['api'].favorite(data['Id'], data['Favorite']) server.jellyfin.favorite(data['Id'], data['Favorite'])
elif method == 'DeleteItem': elif method == 'DeleteItem':
server['api'].delete_item(data['Id']) server.jellyfin.delete_item(data['Id'])
elif method == 'PlayPlaylist': elif method == 'PlayPlaylist':
server['api'].post_session(server['config/app.session'], "Playing", { server.jellyfin.post_session(server['config/app.session'], "Playing", {
'PlayCommand': "PlayNow", 'PlayCommand': "PlayNow",
'ItemIds': data['Id'], 'ItemIds': data['Id'],
'StartPositionTicks': 0 'StartPositionTicks': 0
@ -243,7 +243,7 @@ class Monitor(xbmc.Monitor):
elif method == 'Play': elif method == 'Play':
items = server['api'].get_items(data['ItemIds']) items = server.jellyfin.get_items(data['ItemIds'])
PlaylistWorker(data.get('ServerId'), items, data['PlayCommand'] == 'PlayNow', PlaylistWorker(data.get('ServerId'), items, data['PlayCommand'] == 'PlayNow',
data.get('StartPositionTicks', 0), data.get('AudioStreamIndex'), data.get('StartPositionTicks', 0), data.get('AudioStreamIndex'),
@ -262,7 +262,7 @@ class Monitor(xbmc.Monitor):
self.server_instance(data['ServerId']) self.server_instance(data['ServerId'])
elif method == 'AddUser': elif method == 'AddUser':
server['api'].session_add_user(server['config/app.session'], data['Id'], data['Add']) server.jellyfin.session_add_user(server['config/app.session'], data['Id'], data['Add'])
self.additional_users(server) self.additional_users(server)
elif method == 'Player.OnPlay': elif method == 'Player.OnPlay':
@ -286,20 +286,20 @@ class Monitor(xbmc.Monitor):
elif settings('additionalUsers'): elif settings('additionalUsers'):
users = settings('additionalUsers').split(',') users = settings('additionalUsers').split(',')
all_users = server['api'].get_users() all_users = server.jellyfin.get_users()
for additional in users: for additional in users:
for user in all_users: for user in all_users:
if user['Name'].lower() in additional.decode('utf-8').lower(): if user['Name'].lower() in additional.decode('utf-8').lower():
server['api'].session_add_user(server['config/app.session'], user['Id'], True) server.jellyfin.session_add_user(server['config/app.session'], user['Id'], True)
self.additional_users(server) self.additional_users(server)
def post_capabilities(self, 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['api'].post_capabilities({ server.jellyfin.post_capabilities({
'PlayableMediaTypes': "Audio,Video", 'PlayableMediaTypes': "Audio,Video",
'SupportsMediaControl': True, 'SupportsMediaControl': True,
'SupportedCommands': ( 'SupportedCommands': (
@ -316,7 +316,7 @@ class Monitor(xbmc.Monitor):
'IconUrl': "https://raw.githubusercontent.com/jellyfin/jellyfin-kodi/master/kodi_icon.png", 'IconUrl': "https://raw.githubusercontent.com/jellyfin/jellyfin-kodi/master/kodi_icon.png",
}) })
session = server['api'].get_device(self.device_id) session = server.jellyfin.get_device(self.device_id)
server['config']['app.session'] = session[0]['Id'] server['config']['app.session'] = session[0]['Id']
def additional_users(self, server): def additional_users(self, server):
@ -327,7 +327,7 @@ class Monitor(xbmc.Monitor):
window('JellyfinAdditionalUserImage.%s' % i, clear=True) window('JellyfinAdditionalUserImage.%s' % i, clear=True)
try: try:
session = server['api'].get_device(self.device_id) session = server.jellyfin.get_device(self.device_id)
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
@ -335,7 +335,7 @@ class Monitor(xbmc.Monitor):
for index, user in enumerate(session[0]['AdditionalUsers']): for index, user in enumerate(session[0]['AdditionalUsers']):
info = server['api'].get_user(user['UserId']) 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/auth.server']).get_user_artwork(user['UserId'])
window('JellyfinAdditionalUserImage.%s' % index, image) window('JellyfinAdditionalUserImage.%s' % index, image)
window('JellyfinAdditionalUserPosition.%s' % user['UserId'], str(index)) window('JellyfinAdditionalUserPosition.%s' % user['UserId'], str(index))

View file

@ -721,7 +721,7 @@ def on_update(data, server):
if item: if item:
if not window('jellyfin.skip.%s.bool' % item[0]): if not window('jellyfin.skip.%s.bool' % item[0]):
server['api'].item_played(item[0], playcount) server.jellyfin.item_played(item[0], playcount)
window('jellyfin.skip.%s' % item[0], clear=True) window('jellyfin.skip.%s' % item[0], clear=True)
@ -769,7 +769,7 @@ def on_play(data, server):
return return
item = server['api'].get_item(item[0]) item = server.jellyfin.get_item(item[0])
item['PlaybackInfo'] = {'Path': file} item['PlaybackInfo'] = {'Path': file}
playutils.set_properties(item, 'DirectStream' if settings('useDirectPaths') == '0' else 'DirectPlay') playutils.set_properties(item, 'DirectStream' if settings('useDirectPaths') == '0' else 'DirectPlay')

View file

@ -169,7 +169,7 @@ class Movies(KodiDb):
try: try:
if obj['LocalTrailer']: if obj['LocalTrailer']:
trailer = self.server['api'].get_local_trailers(obj['Id']) trailer = self.server.jellyfin.get_local_trailers(obj['Id'])
obj['Trailer'] = "plugin://plugin.video.jellyfin/trailer?id=%s&mode=play" % trailer[0]['Id'] obj['Trailer'] = "plugin://plugin.video.jellyfin/trailer?id=%s&mode=play" % trailer[0]['Id']
elif obj['Trailer']: elif obj['Trailer']:

View file

@ -217,7 +217,7 @@ class Music(KodiDb):
except TypeError: except TypeError:
try: try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None) self.artist(self.server.jellyfin.get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
@ -318,7 +318,7 @@ class Music(KodiDb):
if obj['SongAlbumId'] is None: if obj['SongAlbumId'] is None:
raise TypeError("No album id found associated?") raise TypeError("No album id found associated?")
self.album(self.server['api'].get_item(obj['SongAlbumId'])) self.album(self.server.jellyfin.get_item(obj['SongAlbumId']))
obj['AlbumId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_song_obj))[0] obj['AlbumId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_song_obj))[0]
except TypeError: except TypeError:
self.single(obj) self.single(obj)
@ -373,7 +373,7 @@ class Music(KodiDb):
except TypeError: except TypeError:
try: try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None) self.artist(self.server.jellyfin.get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
@ -407,7 +407,7 @@ class Music(KodiDb):
except TypeError: except TypeError:
try: try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None) self.artist(self.server.jellyfin.get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)

View file

@ -137,7 +137,7 @@ class TVShows(KodiDb):
season_episodes = {} season_episodes = {}
for season in self.server['api'].get_seasons(obj['Id'])['Items']: for season in self.server.jellyfin.get_seasons(obj['Id'])['Items']:
if season['SeriesId'] != obj['Id']: if season['SeriesId'] != obj['Id']:
obj['SeriesId'] = season['SeriesId'] obj['SeriesId'] = season['SeriesId']
@ -435,7 +435,7 @@ class TVShows(KodiDb):
if obj['ShowId'] is None: if obj['ShowId'] is None:
try: try:
self.tvshow(self.server['api'].get_item(obj['SeriesId']), library=None) self.tvshow(self.server.jellyfin.get_item(obj['SeriesId']), library=None)
obj['ShowId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_series_obj))[0] obj['ShowId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_series_obj))[0]
except (TypeError, KeyError): except (TypeError, KeyError):
LOG.error("Unable to add series %s", obj['SeriesId']) LOG.error("Unable to add series %s", obj['SeriesId'])

View file

@ -110,7 +110,7 @@ class Player(xbmc.Player):
'AudioStreamIndex': item['AudioStreamIndex'], 'AudioStreamIndex': item['AudioStreamIndex'],
'SubtitleStreamIndex': item['SubtitleStreamIndex'] 'SubtitleStreamIndex': item['SubtitleStreamIndex']
} }
item['Server']['api'].session_playing(data) item['Server'].jellyfin.session_playing(data)
window('jellyfin.skip.%s.bool' % item['Id'], True) window('jellyfin.skip.%s.bool' % item['Id'], True)
if monitor.waitForAbort(2): if monitor.waitForAbort(2):
@ -239,7 +239,7 @@ class Player(xbmc.Player):
if item['Type'] != 'Episode' or not item.get('CurrentEpisode'): if item['Type'] != 'Episode' or not item.get('CurrentEpisode'):
return return
next_items = item['Server']['api'].get_adjacent_episodes(item['CurrentEpisode']['tvshowid'], item['Id']) next_items = item['Server'].jellyfin.get_adjacent_episodes(item['CurrentEpisode']['tvshowid'], item['Id'])
for index, next_item in enumerate(next_items['Items']): for index, next_item in enumerate(next_items['Items']):
if next_item['Id'] == item['Id']: if next_item['Id'] == item['Id']:
@ -359,7 +359,7 @@ class Player(xbmc.Player):
'AudioStreamIndex': item['AudioStreamIndex'], 'AudioStreamIndex': item['AudioStreamIndex'],
'SubtitleStreamIndex': item['SubtitleStreamIndex'] 'SubtitleStreamIndex': item['SubtitleStreamIndex']
} }
item['Server']['api'].session_progress(data) item['Server'].jellyfin.session_progress(data)
def onPlayBackStopped(self): def onPlayBackStopped(self):
@ -402,17 +402,17 @@ class Player(xbmc.Player):
'PositionTicks': int(item['CurrentPosition'] * 10000000), 'PositionTicks': int(item['CurrentPosition'] * 10000000),
'PlaySessionId': item['PlaySessionId'] 'PlaySessionId': item['PlaySessionId']
} }
item['Server']['api'].session_stop(data) item['Server'].jellyfin.session_stop(data)
if item.get('LiveStreamId'): if item.get('LiveStreamId'):
LOG.info("<[ livestream/%s ]", item['LiveStreamId']) LOG.info("<[ livestream/%s ]", item['LiveStreamId'])
item['Server']['api'].close_live_stream(item['LiveStreamId']) item['Server'].jellyfin.close_live_stream(item['LiveStreamId'])
elif item['PlayMethod'] == 'Transcode': elif item['PlayMethod'] == 'Transcode':
LOG.info("<[ transcode/%s ]", item['Id']) LOG.info("<[ transcode/%s ]", item['Id'])
item['Server']['api'].close_transcode(item['DeviceId']) item['Server'].jellyfin.close_transcode(item['DeviceId'])
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/temp/").decode('utf-8') path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/temp/").decode('utf-8')
@ -423,7 +423,7 @@ class Player(xbmc.Player):
for file in files: for file in files:
xbmcvfs.delete(os.path.join(path, file.decode('utf-8'))) xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))
result = item['Server']['api'].get_item(item['Id']) or {} result = item['Server'].jellyfin.get_item(item['Id']) or {}
if 'UserData' in result and result['UserData']['Played']: if 'UserData' in result and result['UserData']['Played']:
delete = False delete = False
@ -440,7 +440,7 @@ class Player(xbmc.Player):
LOG.info("Offer delete option") LOG.info("Offer delete option")
if dialog("yesno", heading=_(30091), line1=_(33015), autoclose=120000): if dialog("yesno", heading=_(30091), line1=_(33015), autoclose=120000):
item['Server']['api'].delete_item(item['Id']) item['Server'].jellyfin.delete_item(item['Id'])
window('jellyfin.external_check', clear=True) window('jellyfin.external_check', clear=True)

View file

@ -167,8 +167,8 @@ class Views(object):
def get_libraries(self): def get_libraries(self):
try: try:
libraries = self.server['api'].get_media_folders()['Items'] libraries = self.server.jellyfin.get_media_folders()['Items']
views = self.server['api'].get_views()['Items'] views = self.server.jellyfin.get_views()['Items']
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
raise IndexError("Unable to retrieve libraries: %s" % error) raise IndexError("Unable to retrieve libraries: %s" % error)