added fmframework
This commit is contained in:
parent
2709aecd89
commit
83900a12dd
@ -1,6 +1,5 @@
|
||||
from flask import Blueprint, render_template
|
||||
import requests
|
||||
|
||||
from fmframework.net.network import Network
|
||||
from google.cloud import firestore
|
||||
|
||||
fs = firestore.Client()
|
||||
@ -14,22 +13,7 @@ music_print = Blueprint('music', __name__, template_folder='templates')
|
||||
@music_print.route('/')
|
||||
def root():
|
||||
fmkey = fs.document('key/fm').get().to_dict()['clientid']
|
||||
|
||||
params = {
|
||||
'method': 'user.gettopalbums',
|
||||
'user': 'sarsoo',
|
||||
'period': '1month',
|
||||
'limit': '6',
|
||||
'api_key': fmkey,
|
||||
'format': 'json'
|
||||
}
|
||||
|
||||
req = requests.get(fm_url, params=params)
|
||||
|
||||
albums = req.json()['topalbums']['album']
|
||||
|
||||
for album in albums:
|
||||
for image in album['image']:
|
||||
image['text'] = image['#text']
|
||||
fmnet = Network(username='sarsoo', api_key=fmkey)
|
||||
albums = fmnet.get_top_albums(Network.Range.MONTH, limit=6)
|
||||
|
||||
return render_template('music/index.html', albums=albums)
|
||||
|
@ -9,9 +9,9 @@
|
||||
<div class="row">
|
||||
{% for album in albums %}
|
||||
<div class = "pad-2 card">
|
||||
<img src="{{album.image[3].text}}">
|
||||
<img src="{{album.images[-1].link}}">
|
||||
<p style="text-align:center">{{ album.name }}<br>{{ album.artist.name -}}</p>
|
||||
<p style="text-align:center">{{- album.playcount }} plays</p>
|
||||
<p style="text-align:center">{{- album.play_count }} plays</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user