From 5ec49663e361065c875e2493261bce5eb23a2eee Mon Sep 17 00:00:00 2001 From: RemixDev Date: Tue, 21 Dec 2021 15:14:11 +0100 Subject: [PATCH] try catch loading spotify cache --- deemix/plugins/spotify.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/deemix/plugins/spotify.py b/deemix/plugins/spotify.py index 5d3d487..c34ec28 100644 --- a/deemix/plugins/spotify.py +++ b/deemix/plugins/spotify.py @@ -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):