Skip to content

Commit

Permalink
Add a Refresh context menu
Browse files Browse the repository at this point in the history
The original implementation was very invasive and touched almost every
API to pass a parameter `use_cache` so the specific cache would be
invalidated.

This is easier but as effective.
  • Loading branch information
dagwieers committed Jun 16, 2019
1 parent 9301064 commit 44118e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/lib/__init__.py
Expand Up @@ -136,6 +136,7 @@ class actions:
LISTING_TVGUIDE = 'listingtvguide'
PLAY = 'play'
PLAY_LATEST_EPISODE = 'playlatestepisode'
REFRESH = 'refresh'
REFRESH_FAVORITES = 'refreshfavorites'
SEARCH = 'search'
UNFOLLOW = 'unfollow'
4 changes: 4 additions & 0 deletions resources/lib/router.py
Expand Up @@ -29,6 +29,10 @@ def router(argv):
_kodi.log_access(addon_url, params_string)

# Actions that only require _kodi
if action == actions.REFRESH:
_kodi.invalidate_caches()
_kodi.container_refresh()
return
if action == actions.INVALIDATE_CACHES:
_kodi.invalidate_caches()
return
Expand Down
2 changes: 2 additions & 0 deletions resources/lib/vrtapihelper.py
Expand Up @@ -92,6 +92,7 @@ def _map_to_tvshow_items(self, tvshows, use_favorites=False):
context_menu = [(self._kodi.localize(30411), 'RunPlugin(plugin://plugin.video.vrt.nu?%s)' % urlencode(params))]
else:
context_menu = []
context_menu.append(('Refresh', 'RunPlugin(plugin://plugin.video.vrt.nu?action=%s)' % actions.REFRESH))
# Cut vrtbase url off since it will be added again when searching for episodes
# (with a-z we dont have the full url)
video_url = statichelper.add_https_method(tvshow.get('targetUrl')).replace(self._VRT_BASE, '')
Expand Down Expand Up @@ -308,6 +309,7 @@ def _map_to_episode_items(self, episodes, titletype=None, season_key=None, use_f
context_menu = [(self._kodi.localize(30411), 'RunPlugin(plugin://plugin.video.vrt.nu?%s)' % urlencode(params))]
else:
context_menu = []
context_menu.append(('Refresh', 'RunPlugin(plugin://plugin.video.vrt.nu?action=%s)' % actions.REFRESH))

if self._showfanart:
thumb = statichelper.add_https_method(episode.get('videoThumbnailUrl', 'DefaultAddonVideo.png'))
Expand Down

0 comments on commit 44118e5

Please sign in to comment.