mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Merge pull request #64 from TrueTechy/cleanup-shortcuts
Remove __shortcuts__ in http.py and some in client.py #27
This commit is contained in:
commit
138451d516
14 changed files with 58 additions and 74 deletions
|
@ -148,7 +148,7 @@ class Connect(object):
|
|||
|
||||
''' Save user info.
|
||||
'''
|
||||
self.user = client['api'].get_user()
|
||||
self.user = client.jellyfin.get_user()
|
||||
settings('username', self.user['Name'])
|
||||
|
||||
if 'PrimaryImageTag' in self.user:
|
||||
|
|
|
@ -40,9 +40,7 @@ def browse_info():
|
|||
|
||||
def _http(action, url, request={}, server_id=None):
|
||||
request.update({'url': url, 'type': action})
|
||||
|
||||
return Jellyfin(server_id)['http/request'](request)
|
||||
|
||||
return Jellyfin(server_id).http.request(request)
|
||||
|
||||
def _get(handler, params=None, server_id=None):
|
||||
return _http("GET", get_jellyfinserver_url(handler), {'params': params}, server_id)
|
||||
|
@ -305,7 +303,7 @@ class GetItemWorker(threading.Thread):
|
|||
}
|
||||
|
||||
try:
|
||||
result = self.server['http/request'](request, s)
|
||||
result = self.server.http.request(request, s)
|
||||
|
||||
for item in result['Items']:
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ class FullSync(object):
|
|||
|
||||
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:'):
|
||||
for mixed in ('movies', 'tvshows'):
|
||||
|
|
|
@ -136,7 +136,7 @@ def library_check():
|
|||
view = 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 item['Type'] == 'MusicArtist':
|
||||
|
|
|
@ -88,9 +88,6 @@ class JellyfinClient(object):
|
|||
if key.startswith('config'):
|
||||
return self.config[key.replace('config/', "", 1)] if "/" in key else self.config
|
||||
|
||||
elif key.startswith('http'):
|
||||
return self.http.__shortcuts__(key.replace('http/', "", 1))
|
||||
|
||||
elif key.startswith('websocket'):
|
||||
return self.wsc.__shortcuts__(key.replace('websocket/', "", 1))
|
||||
|
||||
|
@ -100,9 +97,6 @@ class JellyfinClient(object):
|
|||
elif key.startswith('auth'):
|
||||
return self.auth.__shortcuts__(key.replace('auth/', "", 1))
|
||||
|
||||
elif key.startswith('api'):
|
||||
return self.jellyfin
|
||||
|
||||
elif key == 'connected':
|
||||
return self.logged_in
|
||||
|
||||
|
|
|
@ -26,14 +26,6 @@ class HTTP(object):
|
|||
self.client = client
|
||||
self.config = client['config']
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "request":
|
||||
return self.request
|
||||
|
||||
return
|
||||
|
||||
def start_session(self):
|
||||
|
||||
self.session = requests.Session()
|
||||
|
|
|
@ -348,7 +348,7 @@ class Library(threading.Thread):
|
|||
if settings('SyncInstallRunDone.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 not self.fast_sync():
|
||||
|
@ -400,7 +400,7 @@ class Library(threading.Thread):
|
|||
"""
|
||||
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']]
|
||||
"""
|
||||
try:
|
||||
|
@ -409,7 +409,7 @@ class Library(threading.Thread):
|
|||
removed = []
|
||||
|
||||
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['ItemsUpdated'])
|
||||
userdata.extend(result['UserDataChanged'])
|
||||
|
@ -431,7 +431,7 @@ class Library(threading.Thread):
|
|||
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.removed(result['ItemsRemoved'])
|
||||
|
||||
|
@ -439,7 +439,7 @@ class Library(threading.Thread):
|
|||
filters.extend(["tvshows", "boxsets", "musicvideos", "music"])
|
||||
|
||||
# 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['ItemsUpdated'])
|
||||
self.userdata(result['UserDataChanged'])
|
||||
|
|
|
@ -125,22 +125,22 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
if method == 'GetItem':
|
||||
|
||||
item = server['api'].get_item(data['Id'])
|
||||
item = server.jellyfin.get_item(data['Id'])
|
||||
self.void_responder(data, item)
|
||||
|
||||
elif method == 'GetAdditionalParts':
|
||||
|
||||
item = server['api'].get_additional_parts(data['Id'])
|
||||
item = server.jellyfin.get_additional_parts(data['Id'])
|
||||
self.void_responder(data, item)
|
||||
|
||||
elif method == 'GetIntros':
|
||||
|
||||
item = server['api'].get_intros(data['Id'])
|
||||
item = server.jellyfin.get_intros(data['Id'])
|
||||
self.void_responder(data, item)
|
||||
|
||||
elif method == 'GetImages':
|
||||
|
||||
item = server['api'].get_images(data['Id'])
|
||||
item = server.jellyfin.get_images(data['Id'])
|
||||
self.void_responder(data, item)
|
||||
|
||||
elif method == 'GetServerAddress':
|
||||
|
@ -150,12 +150,12 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
elif method == 'GetToken':
|
||||
|
@ -165,31 +165,31 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
elif method == 'GetSession':
|
||||
|
||||
session = server['api'].get_device(self.device_id)
|
||||
session = server.jellyfin.get_device(self.device_id)
|
||||
self.void_responder(data, session)
|
||||
|
||||
elif method == 'GetUsers':
|
||||
|
||||
users = server['api'].get_users()
|
||||
users = server.jellyfin.get_users()
|
||||
self.void_responder(data, users)
|
||||
|
||||
elif method == 'GetTranscodeOptions':
|
||||
|
||||
result = server['api'].get_transcode_settings()
|
||||
result = server.jellyfin.get_transcode_settings()
|
||||
self.void_responder(data, result)
|
||||
|
||||
elif method == 'GetThemes':
|
||||
|
||||
if data['Type'] == 'Video':
|
||||
theme = server['api'].get_items_theme_video(data['Id'])
|
||||
theme = server.jellyfin.get_items_theme_video(data['Id'])
|
||||
else:
|
||||
theme = server['api'].get_items_theme_song(data['Id'])
|
||||
theme = server.jellyfin.get_items_theme_song(data['Id'])
|
||||
|
||||
self.void_responder(data, theme)
|
||||
|
||||
elif method == 'GetTheme':
|
||||
|
||||
theme = server['api'].get_themes(data['Id'])
|
||||
theme = server.jellyfin.get_themes(data['Id'])
|
||||
self.void_responder(data, theme)
|
||||
|
||||
elif method == 'Browse':
|
||||
|
@ -201,41 +201,41 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
elif method == 'BrowseSeason':
|
||||
|
||||
result = server['api'].get_seasons(data['Id'])
|
||||
result = server.jellyfin.get_seasons(data['Id'])
|
||||
self.void_responder(data, result)
|
||||
|
||||
elif method == 'LiveTV':
|
||||
|
||||
result = server['api'].get_channels()
|
||||
result = server.jellyfin.get_channels()
|
||||
self.void_responder(data, result)
|
||||
|
||||
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)
|
||||
|
||||
elif method == 'Genres':
|
||||
|
||||
result = server['api'].get_genres(data.get('Id'))
|
||||
result = server.jellyfin.get_genres(data.get('Id'))
|
||||
self.void_responder(data, result)
|
||||
|
||||
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)
|
||||
|
||||
elif method == 'RefreshItem':
|
||||
server['api'].refresh_item(data['Id'])
|
||||
server.jellyfin.refresh_item(data['Id'])
|
||||
|
||||
elif method == 'FavoriteItem':
|
||||
server['api'].favorite(data['Id'], data['Favorite'])
|
||||
server.jellyfin.favorite(data['Id'], data['Favorite'])
|
||||
|
||||
elif method == 'DeleteItem':
|
||||
server['api'].delete_item(data['Id'])
|
||||
server.jellyfin.delete_item(data['Id'])
|
||||
|
||||
elif method == 'PlayPlaylist':
|
||||
|
||||
server['api'].post_session(server['config/app.session'], "Playing", {
|
||||
server.jellyfin.post_session(server['config/app.session'], "Playing", {
|
||||
'PlayCommand': "PlayNow",
|
||||
'ItemIds': data['Id'],
|
||||
'StartPositionTicks': 0
|
||||
|
@ -243,7 +243,7 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
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',
|
||||
data.get('StartPositionTicks', 0), data.get('AudioStreamIndex'),
|
||||
|
@ -262,7 +262,7 @@ class Monitor(xbmc.Monitor):
|
|||
self.server_instance(data['ServerId'])
|
||||
|
||||
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)
|
||||
|
||||
elif method == 'Player.OnPlay':
|
||||
|
@ -286,20 +286,20 @@ class Monitor(xbmc.Monitor):
|
|||
elif settings('additionalUsers'):
|
||||
|
||||
users = settings('additionalUsers').split(',')
|
||||
all_users = server['api'].get_users()
|
||||
all_users = server.jellyfin.get_users()
|
||||
|
||||
for additional in users:
|
||||
for user in all_users:
|
||||
|
||||
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)
|
||||
|
||||
def post_capabilities(self, server):
|
||||
LOG.info("--[ post capabilities/%s ]", server['auth/server-id'])
|
||||
|
||||
server['api'].post_capabilities({
|
||||
server.jellyfin.post_capabilities({
|
||||
'PlayableMediaTypes': "Audio,Video",
|
||||
'SupportsMediaControl': True,
|
||||
'SupportedCommands': (
|
||||
|
@ -315,7 +315,7 @@ class Monitor(xbmc.Monitor):
|
|||
),
|
||||
})
|
||||
|
||||
session = server['api'].get_device(self.device_id)
|
||||
session = server.jellyfin.get_device(self.device_id)
|
||||
server['config']['app.session'] = session[0]['Id']
|
||||
|
||||
def additional_users(self, server):
|
||||
|
@ -326,7 +326,7 @@ class Monitor(xbmc.Monitor):
|
|||
window('JellyfinAdditionalUserImage.%s' % i, clear=True)
|
||||
|
||||
try:
|
||||
session = server['api'].get_device(self.device_id)
|
||||
session = server.jellyfin.get_device(self.device_id)
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
|
@ -334,7 +334,7 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
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'])
|
||||
window('JellyfinAdditionalUserImage.%s' % index, image)
|
||||
window('JellyfinAdditionalUserPosition.%s' % user['UserId'], str(index))
|
||||
|
|
|
@ -729,7 +729,7 @@ def on_update(data, server):
|
|||
if item:
|
||||
|
||||
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)
|
||||
|
||||
|
@ -777,7 +777,7 @@ def on_play(data, server):
|
|||
|
||||
return
|
||||
|
||||
item = server['api'].get_item(item[0])
|
||||
item = server.jellyfin.get_item(item[0])
|
||||
item['PlaybackInfo'] = {'Path': file}
|
||||
playutils.set_properties(item, 'DirectStream' if settings('useDirectPaths') == '0' else 'DirectPlay')
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ class Movies(KodiDb):
|
|||
try:
|
||||
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']
|
||||
|
||||
elif obj['Trailer']:
|
||||
|
|
|
@ -217,7 +217,7 @@ class Music(KodiDb):
|
|||
except TypeError:
|
||||
|
||||
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]
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
@ -318,7 +318,7 @@ class Music(KodiDb):
|
|||
if obj['SongAlbumId'] is None:
|
||||
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]
|
||||
except TypeError:
|
||||
self.single(obj)
|
||||
|
@ -373,7 +373,7 @@ class Music(KodiDb):
|
|||
except TypeError:
|
||||
|
||||
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]
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
@ -407,7 +407,7 @@ class Music(KodiDb):
|
|||
except TypeError:
|
||||
|
||||
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]
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
|
|
@ -137,7 +137,7 @@ class TVShows(KodiDb):
|
|||
|
||||
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']:
|
||||
obj['SeriesId'] = season['SeriesId']
|
||||
|
@ -435,7 +435,7 @@ class TVShows(KodiDb):
|
|||
if obj['ShowId'] is None:
|
||||
|
||||
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]
|
||||
except (TypeError, KeyError):
|
||||
LOG.error("Unable to add series %s", obj['SeriesId'])
|
||||
|
|
|
@ -110,7 +110,7 @@ class Player(xbmc.Player):
|
|||
'AudioStreamIndex': item['AudioStreamIndex'],
|
||||
'SubtitleStreamIndex': item['SubtitleStreamIndex']
|
||||
}
|
||||
item['Server']['api'].session_playing(data)
|
||||
item['Server'].jellyfin.session_playing(data)
|
||||
window('jellyfin.skip.%s.bool' % item['Id'], True)
|
||||
|
||||
if monitor.waitForAbort(2):
|
||||
|
@ -239,7 +239,7 @@ class Player(xbmc.Player):
|
|||
if item['Type'] != 'Episode' or not item.get('CurrentEpisode'):
|
||||
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']):
|
||||
if next_item['Id'] == item['Id']:
|
||||
|
@ -359,7 +359,7 @@ class Player(xbmc.Player):
|
|||
'AudioStreamIndex': item['AudioStreamIndex'],
|
||||
'SubtitleStreamIndex': item['SubtitleStreamIndex']
|
||||
}
|
||||
item['Server']['api'].session_progress(data)
|
||||
item['Server'].jellyfin.session_progress(data)
|
||||
|
||||
def onPlayBackStopped(self):
|
||||
|
||||
|
@ -402,17 +402,17 @@ class Player(xbmc.Player):
|
|||
'PositionTicks': int(item['CurrentPosition'] * 10000000),
|
||||
'PlaySessionId': item['PlaySessionId']
|
||||
}
|
||||
item['Server']['api'].session_stop(data)
|
||||
item['Server'].jellyfin.session_stop(data)
|
||||
|
||||
if item.get('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':
|
||||
|
||||
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')
|
||||
|
@ -423,7 +423,7 @@ class Player(xbmc.Player):
|
|||
for file in files:
|
||||
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']:
|
||||
delete = False
|
||||
|
@ -440,7 +440,7 @@ class Player(xbmc.Player):
|
|||
LOG.info("Offer delete option")
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ class Views(object):
|
|||
def get_libraries(self):
|
||||
|
||||
try:
|
||||
libraries = self.server['api'].get_media_folders()['Items']
|
||||
views = self.server['api'].get_views()['Items']
|
||||
libraries = self.server.jellyfin.get_media_folders()['Items']
|
||||
views = self.server.jellyfin.get_views()['Items']
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
raise IndexError("Unable to retrieve libraries: %s" % error)
|
||||
|
|
Loading…
Reference in a new issue