From d81d77d9aaf42a8427b66fb60f0d1e424a536a9f Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 12 Sep 2018 23:59:24 -0500 Subject: [PATCH] Adjust views artwork Do not set prop if artwork not available --- resources/lib/downloader.py | 13 ++++++------- resources/lib/views.py | 25 +++++++++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/resources/lib/downloader.py b/resources/lib/downloader.py index 38e7b41b..02a41137 100644 --- a/resources/lib/downloader.py +++ b/resources/lib/downloader.py @@ -105,17 +105,17 @@ def get_filtered_section(parent_id, media=None, limit=None, recursive=None, sort return _get("Users/{UserId}/Items", params, server_id) -def get_movies_by_boxset(boxset_id, server_id=None): +def get_movies_by_boxset(boxset_id): - for items in get_items(boxset_id, "Movie", server_id=server_id): + for items in get_items(boxset_id, "Movie"): yield items -def get_episode_by_show(show_id, server_id=None): +def get_episode_by_show(show_id): - for items in get_items(show_id, "Episode", server_id=server_id): + for items in get_items(show_id, "Episode"): yield items -def get_items(parent_id, item_type=None, basic=False, params=None, server_id=None): +def get_items(parent_id, item_type=None, basic=False, params=None): query = { 'url': "Users/{UserId}/Items", @@ -127,11 +127,10 @@ def get_items(parent_id, item_type=None, basic=False, params=None, server_id=Non 'Fields': api.basic_info() if basic else api.info() } } - if params: query['params'].update(params) - for items in _get_items(query, server_id): + for items in _get_items(query): yield items def get_artists(parent_id=None, basic=False, params=None, server_id=None): diff --git a/resources/lib/views.py b/resources/lib/views.py index 4dd499b3..59a10602 100644 --- a/resources/lib/views.py +++ b/resources/lib/views.py @@ -97,6 +97,7 @@ class Views(object): sync = None limit = 25 + media_folders = None def __init__(self): @@ -730,11 +731,7 @@ class Views(object): window('%s.id' % window_prop, view['Id']) window('%s.path' % window_prop, window_path) window('%s.type' % window_prop, view['Media']) - - if self.server['connected']: - - artwork = api.API(None, self.server['auth/server-address']).get_artwork(view['Id'], 'Primary') - window('%s.artwork' % window_prop, artwork) + self.window_artwork(window_prop, view['Id']) def window_single_node(self, index, item_type, view): @@ -759,7 +756,7 @@ class Views(object): else: path = self.window_path(view, node) - if node in ('browse', 'audiobooks'): + if node in ('browse', 'books', 'audiobooks'): window_path = path else: window_path = "ActivateWindow(Videos,%s,return)" % path @@ -787,11 +784,23 @@ class Views(object): window('%s.id' % window_prop, view['Id']) window('%s.path' % window_prop, window_path) window('%s.type' % window_prop, view['Media']) + self.window_artwork(window_prop, view['Id']) + + def window_artwork(self, prop, view_id): if self.server['connected']: - artwork = api.API(None, self.server['auth/server-address']).get_artwork(view['Id'], 'Primary') - window('%s.artwork' % window_prop, artwork) + if self.media_folders is None: + self.media_folders = self.server['api'].get_media_folders()['Items'] + + for library in self.media_folders: + + if library['Id'] == view_id and 'Primary' in library.get('ImageTags', {}): + + artwork = api.API(None, self.server['auth/server-address']).get_artwork(view_id, 'Primary') + window('%s.artwork' % prop, artwork) + + break def window_path(self, view, node): return "library://video/emby%s%s/%s.xml" % (view['Media'], view['Id'], node)