Skip to content

Commit

Permalink
Make it possible to clear cache
Browse files Browse the repository at this point in the history
The "Discover" route and the client ID are cached
and it should be possible to delete cached files.

Resolves #10
  • Loading branch information
jaylinski committed Apr 18, 2020
1 parent 6c3aac2 commit 64e51f2
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
13 changes: 13 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ msgctxt "#30064"
msgid "disabled"
msgstr "deaktiviert"

msgctxt "#30070"
msgid "Cache"
msgstr "Cache"

msgctxt "#30071"
msgid "Clear cache"
msgstr "Cache leeren"

# GUI - Root
msgctxt "#30101"
msgid "Search"
Expand Down Expand Up @@ -117,6 +125,11 @@ msgctxt "#30302"
msgid "New & hot"
msgstr "Neu und angesagt"

# GUI - Settings
msgctxt "#30501"
msgid "Cache cleared"
msgstr "Cache gelöscht"

# GUI - Generic
msgctxt "#30901"
msgid "Next page"
Expand Down
13 changes: 13 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ msgctxt "#30064"
msgid "disabled"
msgstr ""

msgctxt "#30070"
msgid "Cache"
msgstr ""

msgctxt "#30071"
msgid "Clear cache"
msgstr ""

# GUI - Root
msgctxt "#30101"
msgid "Search"
Expand Down Expand Up @@ -117,6 +125,11 @@ msgctxt "#30302"
msgid "New & hot"
msgstr ""

# GUI - Settings
msgctxt "#30501"
msgid "Cache cleared"
msgstr ""

# GUI - Generic
msgctxt "#30901"
msgid "Next page"
Expand Down
13 changes: 13 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ msgctxt "#30064"
msgid "disabled"
msgstr "uitgeschakeld"

msgctxt "#30070"
msgid "Cache"
msgstr ""

msgctxt "#30071"
msgid "Clear cache"
msgstr "Cache wissen"

# GUI - Root
msgctxt "#30101"
msgid "Search"
Expand Down Expand Up @@ -116,6 +124,11 @@ msgctxt "#30302"
msgid "New & hot"
msgstr "Nieuw & Populair"

# GUI - Settings
msgctxt "#30501"
msgid "Cache cleared"
msgstr "Cache gewist"

# GUI - Generic
msgctxt "#30901"
msgid "Next page"
Expand Down
19 changes: 18 additions & 1 deletion resources/lib/kodi/vfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ def write(self, filename, string):
file = xbmcvfs.File(filepath, "w")
success = file.write(string)
file.close()
return success
return filepath if success else False

def remove_dir(self, path):
dir_list, file_list = xbmcvfs.listdir(path)

for file in file_list:
xbmcvfs.delete(os.path.join(path, file))

for directory in dir_list:
self.remove_dir(os.path.join(path, directory))

xbmcvfs.rmdir(path)

def destroy(self):
"""
Deletes the VFS folder and all files in it.
"""
self.remove_dir(self.path)

def get_mtime(self, filename):
"""
Expand Down
5 changes: 5 additions & 0 deletions resources/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ def run():
else:
xbmc.log("Invalid user action", xbmc.LOGERROR)

elif path == PATH_SETTINGS_CACHE_CLEAR:
vfs_cache.destroy()
dialog = xbmcgui.Dialog()
dialog.ok("SoundCloud", addon.getLocalizedString(30501))

else:
xbmc.log("Path not found", xbmc.LOGERROR)

Expand Down
1 change: 1 addition & 0 deletions resources/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
PATH_PLAY = "/play/"
PATH_SEARCH = "/search/"
PATH_SEARCH_LEGACY = "/search/query/"
PATH_SETTINGS_CACHE_CLEAR = "/settings/cache/clear/"
PATH_USER = "/user/"
2 changes: 2 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
<setting label="30060" type="lsep"/>
<setting id="apiv2.client_id" type="text" label="30061" value="" default="" />
<setting id="apiv2.locale" type="enum" label="30062" lvalues="30063|30064" default="0" />
<setting label="30070" type="lsep"/>
<setting label="30071" type="action" action="RunPlugin(plugin://$ID/settings/cache/clear/)" option="close"/>
</category>
</settings>

0 comments on commit 64e51f2

Please sign in to comment.