Skip to content

Commit

Permalink
Add breadcrumbs support (#436)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dagwieers authored Aug 13, 2019
1 parent 5eaed10 commit d05947a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 22 deletions.
8 changes: 8 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ msgctxt "#30030"
msgid "Remove"
msgstr ""

msgctxt "#30031"
msgid "Search"
msgstr ""

msgctxt "#30032"
msgid "Search results"
msgstr ""


### FAVORITES
msgctxt "#30040"
Expand Down
8 changes: 8 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion resources/lib/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,26 @@ 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

if content:
# 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'
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '''
Expand Down Expand Up @@ -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 '''
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/tvguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '''
Expand Down
28 changes: 14 additions & 14 deletions resources/lib/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand All @@ -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 '''
Expand All @@ -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 '''
Expand All @@ -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 '''
Expand All @@ -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 '''
Expand Down
12 changes: 11 additions & 1 deletion test/xbmcplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d05947a

Please sign in to comment.