diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 9958e38..f8be1db 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -1,5 +1,6 @@ msgid "" msgstr "" +"MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: en\n" @@ -96,6 +97,10 @@ msgctxt "#30702" msgid "An error occurred while authenticating: {error}." msgstr "" +msgctxt "#30707" +msgid "The cache has been cleared." +msgstr "" + msgctxt "#30710" msgid "This video is geo-blocked and can't be played from your location: {error}." msgstr "" @@ -153,3 +158,11 @@ msgstr "" msgctxt "#30884" msgid "Open Kodi Logfile Uploader…" msgstr "" + +msgctxt "#30885" +msgid "Cache" +msgstr "" + +msgctxt "#30886" +msgid "Clear cache" +msgstr "" diff --git a/resources/language/resource.language.nl_nl/strings.po b/resources/language/resource.language.nl_nl/strings.po index 108cb74..329da41 100644 --- a/resources/language/resource.language.nl_nl/strings.po +++ b/resources/language/resource.language.nl_nl/strings.po @@ -97,6 +97,10 @@ msgctxt "#30702" msgid "An error occurred while authenticating: {error}." msgstr "Er is een fout opgetreden tijdens het aanmelden: {error}." +msgctxt "#30707" +msgid "The cache has been cleared." +msgstr "De cache is gewist." + msgctxt "#30710" msgid "This video is geo-blocked and can't be played from your location: {error}." msgstr "Deze video is geografisch geblokkeerd en kan niet worden afgespeeld vanaf je locatie: {error}." @@ -154,3 +158,11 @@ msgstr "Installeer Kodi Logfile Uploader…" msgctxt "#30884" msgid "Open Kodi Logfile Uploader…" msgstr "Open Kodi Logfile Uploader…" + +msgctxt "#30885" +msgid "Cache" +msgstr "Cache" + +msgctxt "#30886" +msgid "Clear cache" +msgstr "Wis cache" diff --git a/resources/lib/addon.py b/resources/lib/addon.py index 6ca9954..ce4fb37 100644 --- a/resources/lib/addon.py +++ b/resources/lib/addon.py @@ -141,6 +141,13 @@ def play_catalog(uuid=None, content_type=None): Player().play(uuid, content_type) +@routing.route('/cache/clear') +def clear_cache(): + """ Clear the cache """ + from resources.lib.modules.catalog import Catalog + Catalog().clear_cache() + + def run(params): """ Run the routing plugin """ kodilogging.config() diff --git a/resources/lib/goplay/content.py b/resources/lib/goplay/content.py index af36bbc..a3cf45f 100644 --- a/resources/lib/goplay/content.py +++ b/resources/lib/goplay/content.py @@ -575,6 +575,7 @@ def _parse_program_data(data): uuid=data.get('programUuid'), path=data.get('programUuid'), channel=data.get('brand'), + category_name=data.get('category') or 'No category', title=data.get('title'), description=html_to_kodi(data.get('description')), aired=datetime.fromtimestamp(data.get('dates', {}).get('publishDate', 0.0) or 0.0), diff --git a/resources/lib/kodiutils.py b/resources/lib/kodiutils.py index 1ffce75..9ba878f 100644 --- a/resources/lib/kodiutils.py +++ b/resources/lib/kodiutils.py @@ -580,6 +580,23 @@ def get_cache_path(): return getattr(get_cache_path, 'cached') +def invalidate_cache(ttl=None): + """ Clear the cache """ + fullpath = get_cache_path() + '/' + + if not xbmcvfs.exists(fullpath): + return + + _, files = xbmcvfs.listdir(fullpath) + import time + now = time.mktime(time.localtime()) + for filename in files: + filepath = os.path.join(fullpath, to_unicode(filename)) + if ttl and now - xbmcvfs.Stat(filepath).st_mtime() < ttl: + continue + xbmcvfs.delete(filepath) + + def get_addon_info(key): """Return addon information""" return to_unicode(ADDON.getAddonInfo(key)) diff --git a/resources/lib/modules/catalog.py b/resources/lib/modules/catalog.py index 011d63f..86848dd 100644 --- a/resources/lib/modules/catalog.py +++ b/resources/lib/modules/catalog.py @@ -106,7 +106,7 @@ def show_season(self, season_uuid): :type season_uuid: str """ try: - episodes = self._api.get_episodes(season_uuid) + episodes = self._api.get_episodes(season_uuid, cache=CACHE_PREVENT) # Use CACHE_PREVENT since we want fresh data except UnavailableException: kodiutils.ok_dialog(message=kodiutils.localize(30717)) # This program is not available in the catalogue. kodiutils.end_of_directory() @@ -218,3 +218,9 @@ def continue_watching(self, index=0): # Sort items by title # Used for A-Z listing or when movies and episodes are mixed. kodiutils.show_listing(listing, 30011, content='tvshows', sort='title') + + @staticmethod + def clear_cache(): + """ Clear the cache """ + kodiutils.invalidate_cache() + kodiutils.notification(message=kodiutils.localize(30707)) diff --git a/resources/settings.xml b/resources/settings.xml index 73efeb3..18f0a78 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -38,7 +38,7 @@ - + 0 false @@ -64,7 +64,19 @@ System.HasAddon(script.kodi.loguploader) | System.AddonIsEnabled(script.kodi.loguploader) - + + + + 0 + + + true + + + RunPlugin(plugin://plugin.video.goplay/cache/clear) + + +