Fixed encoding issues

This commit is contained in:
RemixDev
2021-12-21 12:40:35 +01:00
parent 133314f481
commit 13efa2bc90
6 changed files with 24 additions and 23 deletions

View File

@ -306,14 +306,14 @@ class Spotify(Plugin):
def loadSettings(self):
if not (self.configFolder / 'settings.json').is_file():
with open(self.configFolder / 'settings.json', 'w') as f:
with open(self.configFolder / 'settings.json', 'w', encoding="utf-8") as f:
json.dump({**self.credentials, **self.settings}, f, indent=2)
with open(self.configFolder / 'settings.json', 'r') as settingsFile:
with open(self.configFolder / 'settings.json', 'r', encoding="utf-8") as settingsFile:
try:
settings = json.load(settingsFile)
except json.decoder.JSONDecodeError:
with open(self.configFolder / 'settings.json', 'w') as f:
with open(self.configFolder / 'settings.json', 'w', encoding="utf-8") as f:
json.dump({**self.credentials, **self.settings}, f, indent=2)
settings = deepcopy({**self.credentials, **self.settings})
except Exception:
@ -325,7 +325,7 @@ class Spotify(Plugin):
def saveSettings(self, newSettings=None):
if newSettings: self.setSettings(newSettings)
self.checkCredentials()
with open(self.configFolder / 'settings.json', 'w') as f:
with open(self.configFolder / 'settings.json', 'w', encoding="utf-8") as f:
json.dump({**self.credentials, **self.settings}, f, indent=2)
def getSettings(self):
@ -340,14 +340,14 @@ class Spotify(Plugin):
def loadCache(self):
if (self.configFolder / 'cache.json').is_file():
with open(self.configFolder / 'cache.json', 'r') as f:
with open(self.configFolder / 'cache.json', 'r', encoding="utf-8") as f:
cache = json.load(f)
else:
cache = {'tracks': {}, 'albums': {}}
return cache
def saveCache(self, newCache):
with open(self.configFolder / 'cache.json', 'w') as spotifyCache:
with open(self.configFolder / 'cache.json', 'w', encoding="utf-8") as spotifyCache:
json.dump(newCache, spotifyCache)
def checkCredentials(self):