mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-07 01:16:58 -06:00
fixed location of where tracks where saved (sys.path error), image should now be built upon correct, most recent data
This commit is contained in:
@@ -11,11 +11,11 @@ from .spotify_explicit import main
|
|||||||
path = os.path.join('app/spotify_explicit/recent.json')
|
path = os.path.join('app/spotify_explicit/recent.json')
|
||||||
|
|
||||||
def check_and_update():
|
def check_and_update():
|
||||||
with open(path) as file:
|
try:
|
||||||
try:
|
with open(path) as file:
|
||||||
file = json.load(file)
|
file = json.load(file)
|
||||||
except json.JSONDecodeError:
|
except (FileNotFoundError, json.JSONDecodeError):
|
||||||
file = {'last_generated' : -1}
|
file = {'last_generated' : -1}
|
||||||
|
|
||||||
if file['last_generated'] == -1:
|
if file['last_generated'] == -1:
|
||||||
return True
|
return True
|
||||||
@@ -33,7 +33,7 @@ def check_and_update():
|
|||||||
def spotify():
|
def spotify():
|
||||||
if check_and_update():
|
if check_and_update():
|
||||||
print('Graph out of date - running update command')
|
print('Graph out of date - running update command')
|
||||||
with open(path, 'w') as file:
|
with open(path, 'w+') as file:
|
||||||
file = json.dump({'last_generated' : int(time.time())}, file)
|
file = json.dump({'last_generated' : int(time.time())}, file)
|
||||||
main.main()
|
main.main()
|
||||||
return send_file('spotify_explicit/export/export.png')
|
return send_file('spotify_explicit/export/export.png')
|
||||||
@@ -24,7 +24,7 @@ def main():
|
|||||||
sp = spotipy.Spotify(auth=token)
|
sp = spotipy.Spotify(auth=token)
|
||||||
logging.info('Authorized with Spotify via Spotipy')
|
logging.info('Authorized with Spotify via Spotipy')
|
||||||
|
|
||||||
tracks_folder = os.path.join(sys.path[0], 'tracks')
|
tracks_folder = os.path.join(os.path.dirname(__file__), 'tracks')
|
||||||
logging.warning('Clearing all files in tracks folder for new files')
|
logging.warning('Clearing all files in tracks folder for new files')
|
||||||
if os.path.exists(tracks_folder):
|
if os.path.exists(tracks_folder):
|
||||||
shutil.rmtree(tracks_folder) # Delete folder and all contents (old track files)
|
shutil.rmtree(tracks_folder) # Delete folder and all contents (old track files)
|
||||||
|
|||||||
Reference in New Issue
Block a user