mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-14 20:13:31 -06:00
added full integration of spotify explicit to the website with proper fixes needed
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@ app/static/token.dat
|
||||
.vscode/*
|
||||
keys.json
|
||||
.cache-xevioni
|
||||
auth.json
|
||||
|
||||
@@ -17,6 +17,6 @@ migrate = Migrate(app, db)
|
||||
|
||||
from app import models
|
||||
from app import routes, simple_routes, hidden, dashboard
|
||||
from app import ftbhot, custom, spotify
|
||||
from app import ftbhot, custom, spotify, panzer
|
||||
|
||||
app.jinja_env.globals.update(get_hidden=routes.get_hidden)
|
||||
@@ -1,29 +1,38 @@
|
||||
from app import app
|
||||
from flask import send_from_directory, redirect, url_for, render_template, send_file
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
from flask import send_from_directory, redirect, url_for, render_template, send_file
|
||||
from .spotify_explicit import main
|
||||
|
||||
|
||||
path = os.path.join('app/spotify_explicit/recent.json')
|
||||
|
||||
def check_and_update():
|
||||
path = os.path.join('app/spotify_explicit/recent.json')
|
||||
with open(path) as file:
|
||||
try:
|
||||
file = json.load(file)
|
||||
except json.JSONDecodeError:
|
||||
file = {'last_generated' : -1}
|
||||
regen = time.time() - 3600 >= file['last_generated']
|
||||
if file['last_generated'] != -1:
|
||||
with open(path, 'w') as file:
|
||||
file = json.dump({'last_generated' : int(time.time())}, file)
|
||||
return regen
|
||||
|
||||
if file['last_generated'] == -1:
|
||||
return True
|
||||
else:
|
||||
dif = time.time() - file['last_generated']
|
||||
# print('dif', dif)
|
||||
if dif >= 3600:
|
||||
return True
|
||||
else:
|
||||
ideal = file['last_generated'] + 3600
|
||||
# print(f'Waiting another {int(ideal - time.time())} seconds')
|
||||
return False
|
||||
|
||||
@app.route('/spotify/')
|
||||
def spotify():
|
||||
if check_and_update():
|
||||
from .spotify_explicit import main
|
||||
print('Graph out of date - running update command')
|
||||
with open(path, 'w') as file:
|
||||
file = json.dump({'last_generated' : int(time.time())}, file)
|
||||
main.main()
|
||||
# r = subprocess.run(['python3', '/home/xevion/xevion.dev/app/spotify_explicit/main.py'])
|
||||
return send_file('spotify_explicit/export/export.png')
|
||||
@@ -28,4 +28,5 @@ def refresh():
|
||||
else:
|
||||
pull.main()
|
||||
|
||||
main()
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -73,7 +73,7 @@ def process_data(data):
|
||||
|
||||
# Save the figure, overwriting anything in your way
|
||||
logging.info('Saving the figure to the \'export\' folder')
|
||||
export_folder = os.path.join(sys.path[0], 'export')
|
||||
export_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'export')
|
||||
if not os.path.exists(export_folder):
|
||||
os.makedirs(export_folder)
|
||||
plt.tight_layout()
|
||||
|
||||
Reference in New Issue
Block a user