mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added UI for artist charts
This commit is contained in:
36
website/topartists.py
Normal file
36
website/topartists.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import urllib
|
||||
import json
|
||||
|
||||
|
||||
def replacedict(keys,dbport):
|
||||
from utilities import getArtistInfo
|
||||
|
||||
#hand down the since and from arguments
|
||||
extrakeys = urllib.parse.urlencode(keys)
|
||||
|
||||
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/charts/artists?" + extrakeys)
|
||||
db_data = json.loads(response.read())
|
||||
charts = db_data["list"][:50]
|
||||
topartist = charts[0]["artist"]
|
||||
|
||||
info = getArtistInfo(topartist)
|
||||
imgurl = info.get("image")
|
||||
|
||||
|
||||
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys)
|
||||
db_data = json.loads(response.read())
|
||||
scrobblelist = db_data["list"]
|
||||
scrobbles = len(scrobblelist)
|
||||
|
||||
|
||||
|
||||
|
||||
html = "<table>"
|
||||
for e in charts:
|
||||
html += "<tr><td>"
|
||||
html += "<a href=/artist?artist=" + urllib.parse.quote(e["artist"]) + ">" + e["artist"] + "</a>"
|
||||
html += "</td><td>" + str(e["scrobbles"]) + "</td></tr>"
|
||||
html += "</table>"
|
||||
|
||||
return {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_ARTISTLIST":html}
|
||||
|
||||
Reference in New Issue
Block a user