now playing
This commit is contained in:
parent
f97e52fb29
commit
1196e25a53
2 changed files with 19 additions and 1 deletions
10
site/app.py
10
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():
|
||||
|
|
|
@ -74,4 +74,14 @@
|
|||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<h2>
|
||||
now playing
|
||||
</h2>
|
||||
<p>
|
||||
now playing for <b>{{ user }}</b>: <b>{{ title }}</b> by <b>{{ artist }}</b> from <b>{{ album }}</b> <b>{{ rawData }}</b>
|
||||
<br>
|
||||
<small>
|
||||
data is from listenbrainz.
|
||||
</small>
|
||||
</p>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Reference in a new issue