Added simple spotifyCache validation
This commit is contained in:
parent
9dc52ccaa8
commit
09dba218c2
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
__version__ = "1.4.0"
|
__version__ = "1.4.1"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import eventlet
|
import eventlet
|
||||||
import json
|
import json
|
||||||
import os.path as path
|
import os.path as path
|
||||||
from os import mkdir
|
from os import mkdir, remove
|
||||||
|
|
||||||
eventlet.import_patched('requests.adapters')
|
eventlet.import_patched('requests.adapters')
|
||||||
|
|
||||||
|
@ -50,6 +50,21 @@ class SpotifyHelper:
|
||||||
with open(path.join(self.configFolder, 'authCredentials.json'), 'r') as credentialsFile:
|
with open(path.join(self.configFolder, 'authCredentials.json'), 'r') as credentialsFile:
|
||||||
self.credentials = json.load(credentialsFile)
|
self.credentials = json.load(credentialsFile)
|
||||||
self.checkCredentials()
|
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):
|
def checkCredentials(self):
|
||||||
if self.credentials['clientId'] == "" or self.credentials['clientSecret'] == "":
|
if self.credentials['clientId'] == "" or self.credentials['clientSecret'] == "":
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="deemix",
|
name="deemix",
|
||||||
version="1.4.0",
|
version="1.4.1",
|
||||||
description="A barebone deezer downloader library",
|
description="A barebone deezer downloader library",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
Loading…
Reference in New Issue