From 1196e25a534fdc2f13ae10d7dca6f76110a11ea7b1b3e99c54c07765b3ef35a5 Mon Sep 17 00:00:00 2001 From: Nyx Tutt Date: Mon, 24 Feb 2025 00:02:33 -0600 Subject: [PATCH] now playing --- site/app.py | 10 +++++++++- site/templates/index.j2 | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/site/app.py b/site/app.py index 519de07..62a7457 100644 --- a/site/app.py +++ b/site/app.py @@ -1,6 +1,10 @@ #!/usr/bin/env python from flask import Flask, render_template, make_response +import requests + +apiRoot = "https://api.listenbrainz.org" +user = "everypizza" app = Flask(__name__) @@ -23,7 +27,11 @@ def increment_visitor_count(): @app.route('/') def index(): increment_visitor_count() - return render_template('index.j2', visitor=get_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) @app.route('/assets/index.css') def indexStyle(): diff --git a/site/templates/index.j2 b/site/templates/index.j2 index 13db903..8826d2d 100644 --- a/site/templates/index.j2 +++ b/site/templates/index.j2 @@ -74,4 +74,14 @@

+

+ now playing +

+

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