mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-10 08:09:05 -06:00
created automated graph creation and delivery
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -13,4 +13,5 @@ key
|
||||
/__pycache__/*
|
||||
app/static/token.dat
|
||||
.vscode/*
|
||||
keys.json
|
||||
keys.json
|
||||
.cache-xevioni
|
||||
@@ -16,5 +16,7 @@ db = SQLAlchemy(app)
|
||||
migrate = Migrate(app, db)
|
||||
|
||||
from app import models
|
||||
from app import routes, simple_routes, hidden, dashboard, ftbhot, custom
|
||||
from app import routes, simple_routes, hidden, dashboard
|
||||
from app import ftbhot, custom, spotify
|
||||
|
||||
app.jinja_env.globals.update(get_hidden=routes.get_hidden)
|
||||
27
app/spotify.py
Normal file
27
app/spotify.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from app import app
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
from flask import send_from_directory, redirect, url_for, render_template, send_file
|
||||
|
||||
|
||||
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']
|
||||
with open(path, 'w') as file:
|
||||
file = json.dump({'last_generated' : int(time.time())}, file)
|
||||
return regen
|
||||
|
||||
@app.route('/spotify/')
|
||||
def spotify():
|
||||
if check_and_update():
|
||||
print('Graph out of date - running udpate command')
|
||||
r = subprocess.run(['python', './app/spotify_explicit/main.py'], capture_output=True)
|
||||
# return send_file('spotify_explicit/export/export.png')
|
||||
return render_template('spotify.html')
|
||||
1
app/spotify_explicit
Submodule
1
app/spotify_explicit
Submodule
Submodule app/spotify_explicit added at 9bd5b0c789
1
app/templates/spotify.html
Normal file
1
app/templates/spotify.html
Normal file
@@ -0,0 +1 @@
|
||||
<img src="{{ url_for('static', filename='../spotify_explicit/export/export.png') }}">
|
||||
Reference in New Issue
Block a user