From d05947ab59f5820514f6ca27e301b4084112168b Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 14 Aug 2019 01:05:03 +0200 Subject: [PATCH] Add breadcrumbs support (#436) This is the final piece in the visual styling of the add-on. It wasn't always clear in what menu you were visually, this fixes it. --- .../resource.language.en_gb/strings.po | 8 ++++++ .../resource.language.nl_nl/strings.po | 8 ++++++ resources/lib/kodiwrapper.py | 10 ++++++- resources/lib/search.py | 4 +-- resources/lib/tvguide.py | 8 +++--- resources/lib/vrtplayer.py | 28 +++++++++---------- test/xbmcplugin.py | 12 +++++++- 7 files changed, 56 insertions(+), 22 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 4e4ed684..8eb22513 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -100,6 +100,14 @@ msgctxt "#30030" msgid "Remove" msgstr "" +msgctxt "#30031" +msgid "Search" +msgstr "" + +msgctxt "#30032" +msgid "Search results" +msgstr "" + ### FAVORITES msgctxt "#30040" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index 0f1ae1f1..5129d3c5 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -101,6 +101,14 @@ msgctxt "#30030" msgid "Remove" msgstr "Verwijder" +msgctxt "#30031" +msgid "Search" +msgstr "Zoeken" + +msgctxt "#30032" +msgid "Search results" +msgstr "Zoekresultaten" + ### FAVORITES msgctxt "#30040" diff --git a/resources/lib/kodiwrapper.py b/resources/lib/kodiwrapper.py index 58d0e578..b66e43cd 100644 --- a/resources/lib/kodiwrapper.py +++ b/resources/lib/kodiwrapper.py @@ -146,11 +146,13 @@ def install_widevine(self): self.show_notification(heading=self.localize(30971), message=self.localize(30973), icon='error', time=5000) self.end_of_directory() - def show_listing(self, list_items, sort='unsorted', ascending=True, content=None, cache=None): + def show_listing(self, list_items, category=None, sort='unsorted', ascending=True, content=None, cache=None): ''' Show a virtual directory in Kodi ''' from xbmcgui import ListItem listing = [] + xbmcplugin.setPluginFanart(handle=self._handle, image=self._addon_fanart) + if cache is None: cache = self._usemenucaching @@ -158,6 +160,12 @@ def show_listing(self, list_items, sort='unsorted', ascending=True, content=None # content is one of: files, songs, artists, albums, movies, tvshows, episodes, musicvideos xbmcplugin.setContent(self._handle, content=content) + if category: + if isinstance(category, int): + xbmcplugin.setPluginCategory(handle=self._handle, category=self.localize(category)) + else: + xbmcplugin.setPluginCategory(handle=self._handle, category=category) + # FIXME: Since there is no way to influence descending order, we force it here if not ascending: sort = 'unsorted' diff --git a/resources/lib/search.py b/resources/lib/search.py index 201d322d..47182c64 100644 --- a/resources/lib/search.py +++ b/resources/lib/search.py @@ -55,7 +55,7 @@ def search_menu(self): is_playable=False, )) - self._kodi.show_listing(menu_items) + self._kodi.show_listing(menu_items, category=30031) def search(self, keywords=None, page=None): ''' The VRT NU add-on Search functionality and results ''' @@ -88,7 +88,7 @@ def search(self, keywords=None, page=None): )) self._favorites.get_favorites(ttl=60 * 60) - self._kodi.show_listing(search_items, sort=sort, ascending=ascending, content=content, cache=False) + self._kodi.show_listing(search_items, category=30032, sort=sort, ascending=ascending, content=content, cache=False) def clear(self): ''' Clear the search history ''' diff --git a/resources/lib/tvguide.py b/resources/lib/tvguide.py index d01756e5..1229d7d0 100644 --- a/resources/lib/tvguide.py +++ b/resources/lib/tvguide.py @@ -54,19 +54,19 @@ def show_tvguide(self, date=None, channel=None): if not date and not channel: date_items = self.get_date_items() - self._kodi.show_listing(date_items, content='files') + self._kodi.show_listing(date_items, category=30026, content='files') # TV guide elif not channel: channel_items = self.get_channel_items(date=date) - self._kodi.show_listing(channel_items) + self._kodi.show_listing(channel_items, category=date) elif not date: date_items = self.get_date_items(channel=channel) - self._kodi.show_listing(date_items, content='files') + self._kodi.show_listing(date_items, category=channel, content='files') else: episode_items = self.get_episode_items(date, channel) - self._kodi.show_listing(episode_items, content='episodes', cache=False) + self._kodi.show_listing(episode_items, category='%s / %s' % (channel, date), content='episodes', cache=False) def get_date_items(self, channel=None): ''' Offer a menu to select the TV-guide date ''' diff --git a/resources/lib/vrtplayer.py b/resources/lib/vrtplayer.py index 65e1db73..ed64fca1 100644 --- a/resources/lib/vrtplayer.py +++ b/resources/lib/vrtplayer.py @@ -69,7 +69,7 @@ def show_main_menu(self): art_dict=dict(thumb='DefaultAddonsSearch.png'), info_dict=dict(plot=self._kodi.localize(30029))), ]) - self._kodi.show_listing(main_items) + self._kodi.show_listing(main_items) # No category self._version_check() def _version_check(self): @@ -140,7 +140,7 @@ def show_favorites_menu(self): info_dict=dict(plot=self._kodi.localize(30045))), ) - self._kodi.show_listing(favorites_items) + self._kodi.show_listing(favorites_items, category=30010) # My programs # Show dialog when no favorites were found if not self._favorites.titles(): @@ -150,24 +150,24 @@ def show_favorites_docu_menu(self): ''' The VRT NU add-on 'My documentaries' listing menu ''' self._favorites.get_favorites(ttl=60 * 60) episode_items, sort, ascending, content = self._apihelper.list_episodes(category='docu', season='allseasons', programtype='oneoff') - self._kodi.show_listing(episode_items, sort=sort, ascending=ascending, content=content) + self._kodi.show_listing(episode_items, category=30044, sort=sort, ascending=ascending, content=content) def show_tvshow_menu(self, use_favorites=False): ''' The VRT NU add-on 'A-Z' listing menu ''' # My programs menus may need more up-to-date favorites self._favorites.get_favorites(ttl=5 * 60 if use_favorites else 60 * 60) tvshow_items = self._apihelper.list_tvshows(use_favorites=use_favorites) - self._kodi.show_listing(tvshow_items, sort='label', content='tvshows') + self._kodi.show_listing(tvshow_items, category=30012, sort='label', content='tvshows') def show_category_menu(self, category=None): ''' The VRT NU add-on 'Categories' listing menu ''' if category: self._favorites.get_favorites(ttl=60 * 60) tvshow_items = self._apihelper.list_tvshows(category=category) - self._kodi.show_listing(tvshow_items, sort='label', content='tvshows') + self._kodi.show_listing(tvshow_items, category=category, sort='label', content='tvshows') else: category_items = self._apihelper.list_categories() - self._kodi.show_listing(category_items, sort='unsorted', content='files') + self._kodi.show_listing(category_items, category=30014, sort='unsorted', content='files') # Categories def show_channels_menu(self, channel=None): ''' The VRT NU add-on 'Channels' listing menu ''' @@ -178,31 +178,31 @@ def show_channels_menu(self, channel=None): tvguide_item = TVGuide(self._kodi).get_channel_items(channel=channel) youtube_item = self._apihelper.list_youtube(channels=[channel]) tvshow_items = self._apihelper.list_tvshows(channel=channel) - self._kodi.show_listing(livetv_item + tvguide_item + youtube_item + tvshow_items, sort='unsorted', content='tvshows') + self._kodi.show_listing(livetv_item + tvguide_item + youtube_item + tvshow_items, category=channel, sort='unsorted', content='tvshows') # Channels else: channel_items = self._apihelper.list_channels(live=False) - self._kodi.show_listing(channel_items, cache=False) + self._kodi.show_listing(channel_items, category=30016, cache=False) def show_featured_menu(self, feature=None): ''' The VRT NU add-on 'Featured content' listing menu ''' if feature: self._favorites.get_favorites(ttl=60 * 60) tvshow_items = self._apihelper.list_tvshows(feature=feature) - self._kodi.show_listing(tvshow_items, sort='label', content='tvshows') + self._kodi.show_listing(tvshow_items, category=feature, sort='label', content='tvshows') else: featured_items = self._apihelper.list_featured() - self._kodi.show_listing(featured_items, sort='label', content='files') + self._kodi.show_listing(featured_items, category=30024, sort='label', content='files') def show_livetv_menu(self): ''' The VRT NU add-on 'Live TV' listing menu ''' channel_items = self._apihelper.list_channels() - self._kodi.show_listing(channel_items, cache=False) + self._kodi.show_listing(channel_items, category=30018, cache=False) def show_episodes_menu(self, program, season=None): ''' The VRT NU add-on episodes listing menu ''' self._favorites.get_favorites(ttl=60 * 60) episode_items, sort, ascending, content = self._apihelper.list_episodes(program=program, season=season) - self._kodi.show_listing(episode_items, sort=sort, ascending=ascending, content=content) + self._kodi.show_listing(episode_items, category=program, sort=sort, ascending=ascending, content=content) def show_recent_menu(self, page=0, use_favorites=False): ''' The VRT NU add-on 'Most recent' and 'My most recent' listing menu ''' @@ -226,7 +226,7 @@ def show_recent_menu(self, page=0, use_favorites=False): info_dict=dict(), )) - self._kodi.show_listing(episode_items, sort=sort, ascending=ascending, content=content, cache=False) + self._kodi.show_listing(episode_items, category=30020, sort=sort, ascending=ascending, content=content, cache=False) def show_offline_menu(self, page=0, use_favorites=False): ''' The VRT NU add-on 'Soon offline' and 'My soon offline' listing menu ''' @@ -250,7 +250,7 @@ def show_offline_menu(self, page=0, use_favorites=False): info_dict=dict(), )) - self._kodi.show_listing(episode_items, sort=sort, ascending=ascending, content=content) + self._kodi.show_listing(episode_items, category=30022, sort=sort, ascending=ascending, content=content) def play_latest_episode(self, program): ''' A hidden feature in the VRT NU add-on to play the latest episode of a program ''' diff --git a/test/xbmcplugin.py b/test/xbmcplugin.py index f075da3d..cef0886c 100644 --- a/test/xbmcplugin.py +++ b/test/xbmcplugin.py @@ -57,11 +57,21 @@ def endOfDirectory(handle, succeeded=True, updateListing=True, cacheToDisc=True) return -def setContent(self, content): +def setContent(handle, content): ''' A stub implementation of the xbmcplugin setContent() function ''' return +def setPluginFanart(handle, image, color1=None, color2=None, color3=None): + ''' A stub implementation of the xbmcplugin setCategoryt() function ''' + return + + +def setPluginCategory(handle, category): + ''' A reimplementation of the xbmcplugin setPluginCategory() function ''' + print(kodi_to_ansi('[B]** %s **[/B]' % category)) + + def setResolvedUrl(handle, succeeded, listitem): ''' A stub implementation of the xbmcplugin setResolvedUrl() function ''' return