Added simple spotifyCache validation

This commit is contained in:
RemixDev 2020-09-20 18:32:39 +02:00
parent 9dc52ccaa8
commit 09dba218c2
3 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env python3
__version__ = "1.4.0"
__version__ = "1.4.1"

View File

@ -1,7 +1,7 @@
import eventlet
import json
import os.path as path
from os import mkdir
from os import mkdir, remove
eventlet.import_patched('requests.adapters')
@ -50,6 +50,21 @@ class SpotifyHelper:
with open(path.join(self.configFolder, 'authCredentials.json'), 'r') as credentialsFile:
self.credentials = json.load(credentialsFile)
self.checkCredentials()
self.checkValidCache()
def checkValidCache(self):
if path.isfile(path.join(self.configFolder, 'spotifyCache.json')):
with open(path.join(self.configFolder, 'spotifyCache.json'), 'r') as spotifyCache:
try:
cache = json.load(spotifyCache)
except Exception as e:
print(str(e))
remove(path.join(self.configFolder, 'spotifyCache.json'))
return
# Remove old versions of cache
if len(cache['tracks'].values()) and isinstance(list(cache['tracks'].values())[0], int) or \
len(cache['albums'].values()) and isinstance(list(cache['albums'].values())[0], int):
remove(path.join(self.configFolder, 'spotifyCache.json'))
def checkCredentials(self):
if self.credentials['clientId'] == "" or self.credentials['clientSecret'] == "":

View File

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup(
name="deemix",
version="1.4.0",
version="1.4.1",
description="A barebone deezer downloader library",
long_description=README,
long_description_content_type="text/markdown",