From 44118e575a32665af0ca091c40517bc91db41f74 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Sun, 16 Jun 2019 22:57:00 +0200 Subject: [PATCH] Add a Refresh context menu 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. --- resources/lib/__init__.py | 1 + resources/lib/router.py | 4 ++++ resources/lib/vrtapihelper.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/resources/lib/__init__.py b/resources/lib/__init__.py index d09d60739..145a23aa0 100644 --- a/resources/lib/__init__.py +++ b/resources/lib/__init__.py @@ -136,6 +136,7 @@ class actions: LISTING_TVGUIDE = 'listingtvguide' PLAY = 'play' PLAY_LATEST_EPISODE = 'playlatestepisode' + REFRESH = 'refresh' REFRESH_FAVORITES = 'refreshfavorites' SEARCH = 'search' UNFOLLOW = 'unfollow' diff --git a/resources/lib/router.py b/resources/lib/router.py index bfbd80767..324143594 100644 --- a/resources/lib/router.py +++ b/resources/lib/router.py @@ -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 diff --git a/resources/lib/vrtapihelper.py b/resources/lib/vrtapihelper.py index 76785b915..bdb1d3375 100644 --- a/resources/lib/vrtapihelper.py +++ b/resources/lib/vrtapihelper.py @@ -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, '') @@ -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'))