diff --git a/site/app.py b/site/app.py index 62a7457..8e246d0 100644 --- a/site/app.py +++ b/site/app.py @@ -1,11 +1,24 @@ #!/usr/bin/env python -from flask import Flask, render_template, make_response +from flask import Flask, render_template, make_response, send_from_directory import requests +import os apiRoot = "https://api.listenbrainz.org" user = "everypizza" +buttons = [ + ("assets/88x31s/benjae.nekoweb.org.gif", "https://benjae.nekoweb.org"), + ("assets/88x31s/freetards.xyz.gif", "https://freetards.xyz"), + ("assets/88x31s/fsky.io.webp", "https://fsky.io"), + ("assets/88x31s/nyx.everypizza.im.webp", "https://nyx.everypizza.im"), + ("assets/88x31s/purplebored.pl.gif", "https://purplebored.pl"), + ("assets/88x31s/squarebowl.club.gif", "https://squarebowl.club"), + ("assets/88x31s/synth.download.svg", "https://synth.download"), + ("assets/88x31s/telepath.im.png", "https://telepath.im"), + ("assets/88x31s/voxel.fsky.io.webp", "https://voxel.fsky.io"), +] + app = Flask(__name__) countFile = "visitorCount.txt" @@ -28,10 +41,16 @@ def increment_visitor_count(): def index(): increment_visitor_count() data = requests.get(apiRoot + "/1/user/" + user + "/playing-now") - track = data.json()['payload']['listens'][0]['track_metadata']['track_name'] - artist = data.json()['payload']['listens'][0]['track_metadata']['artist_name'] - album = data.json()['payload']['listens'][0]['track_metadata']['release_name'] - return render_template('index.j2', visitor=get_visitor_count(), user=user, title=track, artist=artist, album=album) + if not data.json()['payload']['listens']: + nowPlaying = False + nowPlayingString = "nothing is playing right now." + else: + track = data.json()['payload']['listens'][0]['track_metadata']['track_name'] + artist = data.json()['payload']['listens'][0]['track_metadata']['artist_name'] + album = data.json()['payload']['listens'][0]['track_metadata']['release_name'] + nowPlayingString = f"now playing for {user}: {track} by {artist} from {album}" + + return render_template('index.j2', np=nowPlayingString, visitor=get_visitor_count(), buttons=buttons) @app.route('/assets/index.css') def indexStyle(): @@ -40,5 +59,14 @@ def indexStyle(): response.mimetype = "text/css" return response +@app.route('/static/assets/88x31s/') +def serve_dir(filename): + directory = 'templates/assets/88x31s' + return send_from_directory(directory, filename) + +@app.route('/todo') +def todo(): + return render_template('todo.html') + if __name__ == '__main__': app.run(host="0.0.0.0", port=8080) diff --git a/site/templates/assets/88x31s/benjae.nekoweb.org.gif b/site/templates/assets/88x31s/benjae.nekoweb.org.gif new file mode 100644 index 0000000..6c3315b Binary files /dev/null and b/site/templates/assets/88x31s/benjae.nekoweb.org.gif differ diff --git a/site/templates/assets/88x31s/freetards.xyz.gif b/site/templates/assets/88x31s/freetards.xyz.gif new file mode 100644 index 0000000..44f7c27 Binary files /dev/null and b/site/templates/assets/88x31s/freetards.xyz.gif differ diff --git a/site/templates/assets/88x31s/fsky.io.webp b/site/templates/assets/88x31s/fsky.io.webp new file mode 100644 index 0000000..720bc57 Binary files /dev/null and b/site/templates/assets/88x31s/fsky.io.webp differ diff --git a/site/templates/assets/88x31s/nyx.everypizza.im.webp b/site/templates/assets/88x31s/nyx.everypizza.im.webp new file mode 100644 index 0000000..7cda561 Binary files /dev/null and b/site/templates/assets/88x31s/nyx.everypizza.im.webp differ diff --git a/site/templates/assets/88x31s/purplebored.pl.gif b/site/templates/assets/88x31s/purplebored.pl.gif new file mode 100644 index 0000000..deaa083 Binary files /dev/null and b/site/templates/assets/88x31s/purplebored.pl.gif differ diff --git a/site/templates/assets/88x31s/squarebowl.club.gif b/site/templates/assets/88x31s/squarebowl.club.gif new file mode 100644 index 0000000..75f2148 Binary files /dev/null and b/site/templates/assets/88x31s/squarebowl.club.gif differ diff --git a/site/templates/assets/88x31s/synth.download.svg b/site/templates/assets/88x31s/synth.download.svg new file mode 100644 index 0000000..de7ded1 --- /dev/null +++ b/site/templates/assets/88x31s/synth.download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/templates/assets/88x31s/telepath.im.png b/site/templates/assets/88x31s/telepath.im.png new file mode 100644 index 0000000..c2b1c4a Binary files /dev/null and b/site/templates/assets/88x31s/telepath.im.png differ diff --git a/site/templates/assets/88x31s/voxel.fsky.io.webp b/site/templates/assets/88x31s/voxel.fsky.io.webp new file mode 100644 index 0000000..f92bb0e Binary files /dev/null and b/site/templates/assets/88x31s/voxel.fsky.io.webp differ diff --git a/site/templates/assets/broken/isekai.rocks.svg b/site/templates/assets/broken/isekai.rocks.svg new file mode 100644 index 0000000..7c56724 --- /dev/null +++ b/site/templates/assets/broken/isekai.rocks.svg @@ -0,0 +1 @@ +
>Snit was here
diff --git a/site/templates/index.j2 b/site/templates/index.j2 index 8826d2d..41600a0 100644 --- a/site/templates/index.j2 +++ b/site/templates/index.j2 @@ -70,7 +70,7 @@

@@ -78,10 +78,20 @@ now playing

- now playing for {{ user }}: {{ title }} by {{ artist }} from {{ album }} {{ rawData }} + {{ np }}
data is from listenbrainz.

+

+ 88x31s +

+

+ {% for image, link in buttons %} + + {{ image }} + + {% endfor %} +