try catch loading spotify cache

This commit is contained in:
RemixDev 2021-12-21 15:14:11 +01:00
parent 6a6ec400db
commit 5ec49663e3
No known key found for this signature in database
GPG Key ID: B33962B465BDB51C
1 changed files with 9 additions and 3 deletions

View File

@ -338,11 +338,17 @@ class Spotify(Plugin):
self.settings = settings
def loadCache(self):
cache = None
if (self.configFolder / 'cache.json').is_file():
with open(self.configFolder / 'cache.json', 'r', encoding="utf-8") as f:
cache = json.load(f)
else:
cache = {'tracks': {}, 'albums': {}}
try:
cache = json.load(f)
except json.decoder.JSONDecodeError:
self.saveCache({'tracks': {}, 'albums': {}})
cache = None
except Exception:
cache = None
if not cache: cache = {'tracks': {}, 'albums': {}}
return cache
def saveCache(self, newCache):