From 7b2ee9d4ba3f2479eb9ab055bce2d4b2e33c2413 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sat, 22 Sep 2018 03:28:39 -0500 Subject: [PATCH] Add subfolders for dynamic movies --- .../resource.language.en_gb/strings.po | 4 +-- resources/lib/downloader.py | 7 +++-- resources/lib/entrypoint/default.py | 26 ++++++++++++++----- resources/lib/monitor.py | 9 ++----- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 6bc86c9a..303dc6a4 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -839,7 +839,7 @@ msgid "Unwatched" msgstr "" msgctxt "#33171" -msgid "A-Z" +msgid "By first letter" msgstr "" msgctxt "#33172" @@ -847,5 +847,5 @@ msgid "You have {number} updates pending. This may take a little while before se msgstr "" msgctxt "#33173" -msgid "Forget about the previous sync?" +msgid "Forget about the previous sync? This is not recommended." msgstr "" diff --git a/resources/lib/downloader.py b/resources/lib/downloader.py index 24ba1ef5..e94b3e62 100644 --- a/resources/lib/downloader.py +++ b/resources/lib/downloader.py @@ -78,8 +78,8 @@ def get_single_item(parent_id, media): 'IncludeItemTypes': media }) -def get_filtered_section(parent_id, media=None, limit=None, recursive=None, sort=None, sort_order=None, - filters=None, server_id=None): +def get_filtered_section(parent_id=None, media=None, limit=None, recursive=None, sort=None, sort_order=None, + filters=None, extra=None, server_id=None): ''' Get dynamic listings. ''' @@ -110,6 +110,9 @@ def get_filtered_section(parent_id, media=None, limit=None, recursive=None, sort if media and 'Photo' in media: params['Fields'] += ",Width,Height" + if extra is not None: + params.update(extra) + return _get("Users/{UserId}/Items", params, server_id) def get_movies_by_boxset(boxset_id): diff --git a/resources/lib/entrypoint/default.py b/resources/lib/entrypoint/default.py index 6462c30c..614a5755 100644 --- a/resources/lib/entrypoint/default.py +++ b/resources/lib/entrypoint/default.py @@ -231,7 +231,7 @@ def browse(media, view_id=None, folder=None, server_id=None): folder = folder.lower() if folder else None - if folder is None and media in ('homevideos'): + if folder is None and media in ('homevideos', 'movies'): return browse_subfolders(media, view_id, server_id) if folder and folder == 'firstletter': @@ -263,12 +263,13 @@ def browse(media, view_id=None, folder=None, server_id=None): elif folder == 'inprogress': listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Filters': ['IsResumable']}).get() elif folder == 'boxsets': - listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Recursive': True}).get() + listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type('boxsets'), 'Recursive': True}).get() elif folder == 'random': - listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), - 'Sort': "Random", 'Limit': 25, 'Recursive': True}).get() - elif (folder or "").startswith('firstletter'): - listing = TheVoid('NameStartsWith', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Filters': folder.split('-')[1]}).get() + listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Sort': "Random", 'Limit': 25, 'Recursive': True}).get() + elif (folder or "").startswith('firstletter-'): + listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'NameStartsWith': folder.split('-')[1]}}).get() + elif (folder or "").startswith('genres-'): + listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'GenreIds': folder.split('genres-')[1]}}).get() elif folder == 'favepisodes': listing = TheVoid('Browse', {'Media': get_media_type(content_type), 'ServerId': server_id, 'Limit': 25, 'Filters': ['IsFavorite']}).get() elif media == 'homevideos': @@ -324,6 +325,19 @@ def browse(media, view_id=None, folder=None, server_id=None): li.addContextMenuItems(context) list_li.append((path, li, True)) + + elif item['Type'] == 'Genre': + + params = { + 'id': view_id or item['Id'], + 'mode': "browse", + 'type': get_folder_type(item) or media, + 'folder': 'genres-%s' % item['Id'], + 'server': server_id + } + path = "%s?%s" % ("plugin://plugin.video.emby/", urllib.urlencode(params)) + list_li.append((path, li, True)) + else: if item['Type'] not in ('Photo', 'PhotoAlbum'): params = { diff --git a/resources/lib/monitor.py b/resources/lib/monitor.py index b3980b6c..f979107b 100644 --- a/resources/lib/monitor.py +++ b/resources/lib/monitor.py @@ -56,7 +56,7 @@ class Monitor(xbmc.Monitor): 'PlayPlaylist', 'Play', 'GetIntros', 'GetAdditionalParts', 'RefreshItem', 'Genres', 'FavoriteItem', 'DeleteItem', 'AddUser', 'GetSession', 'GetUsers', 'GetThemes', 'GetTheme', 'Playstate', 'GeneralCommand', 'GetTranscodeOptions', 'RecentlyAdded', - 'NameStartsWith', 'BrowseSeason'): + 'BrowseSeason'): return data = json.loads(data)[0] @@ -160,7 +160,7 @@ class Monitor(xbmc.Monitor): result = downloader.get_filtered_section(data.get('Id'), data.get('Media'), data.get('Limit'), data.get('Recursive'), data.get('Sort'), data.get('SortOrder'), - data.get('Filters'), data.get('ServerId')) + data.get('Filters'), data.get('Params'), data.get('ServerId')) self.void_responder(data, result) elif method == 'BrowseSeason': @@ -178,11 +178,6 @@ class Monitor(xbmc.Monitor): result = server['api'].get_genres(data.get('Id')) self.void_responder(data, result) - elif method == 'NameStartsWith': - - result = server['api'].get_items_by_letter(data.get('Id'), data.get('Media'), data.get('Filters')) - self.void_responder(data, result) - elif method == 'Recommended': result = server['api'].get_recommendation(data.get('Id'), data.get('Limit'))