diff --git a/sarsoo/music/music.py b/sarsoo/music/music.py index d4bc338..9c953a8 100644 --- a/sarsoo/music/music.py +++ b/sarsoo/music/music.py @@ -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) diff --git a/sarsoo/music/templates/music/index.html b/sarsoo/music/templates/music/index.html index f7d0d7d..365e343 100644 --- a/sarsoo/music/templates/music/index.html +++ b/sarsoo/music/templates/music/index.html @@ -9,9 +9,9 @@
{{ album.name }}
{{ album.artist.name -}}
{{- album.playcount }} plays
+{{- album.play_count }} plays