mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added pulse on artist and track pages
This commit is contained in:
parent
5e98338c2a
commit
a4b95969d5
@ -26,5 +26,9 @@
|
||||
<h2><a href='/toptracks?artist=KEY_ENC_ARTISTNAME'>Tracks</a></h2>
|
||||
KEY_TRACKLIST
|
||||
|
||||
|
||||
<h2><a href='/pulse?artist=KEY_ENC_ARTISTNAME&step=year&trail=1'>Pulse</a></h2>
|
||||
KEY_PULSE
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -4,7 +4,7 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, getRangeDesc, scrobblesLink
|
||||
|
||||
clean(keys)
|
||||
info = getArtistInfo(keys["artist"])
|
||||
@ -45,7 +45,29 @@ def instructions(keys,dbport):
|
||||
html += "</table>"
|
||||
|
||||
|
||||
# pulse
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=year&trail=1&artist=" + urllib.parse.quote(keys["artist"]))
|
||||
db_data = json.loads(response.read())
|
||||
terms = db_data["list"]
|
||||
|
||||
# build list
|
||||
maxbar = max([t["scrobbles"] for t in terms])
|
||||
|
||||
html_pulse = "<table class='list'>"
|
||||
for t in terms:
|
||||
fromstr = "/".join([str(e) for e in t["from"]])
|
||||
tostr = "/".join([str(e) for e in t["to"]])
|
||||
html_pulse += "<tr>"
|
||||
#html += "<td>" + fromstr + "</td>"
|
||||
#html += "<td>" + tostr + "</td>"
|
||||
html_pulse += "<td>" + getRangeDesc(t["from"],t["to"]) + "</td>"
|
||||
html_pulse += "<td class='amount'>" + scrobblesLink({"since":fromstr,"to":tostr},amount=t["scrobbles"],artist=keys["artist"]) + "</td>"
|
||||
html_pulse += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,artist=keys["artist"]) + "</td>"
|
||||
html_pulse += "</tr>"
|
||||
html_pulse += "</table>"
|
||||
|
||||
|
||||
|
||||
replace = {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":"","KEY_TRACKLIST":html,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr}
|
||||
replace = {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":"","KEY_TRACKLIST":html,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr,"KEY_PULSE":html_pulse}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
@ -52,7 +52,6 @@ def instructions(keys,dbport):
|
||||
# build list
|
||||
maxbar = max([t["scrobbles"] for t in terms])
|
||||
|
||||
i = 1
|
||||
html = "<table class='list'>"
|
||||
for t in terms:
|
||||
fromstr = "/".join([str(e) for e in t["from"]])
|
||||
@ -64,7 +63,6 @@ def instructions(keys,dbport):
|
||||
html += "<td class='amount'>" + scrobblesLink({"since":fromstr,"to":tostr},amount=t["scrobbles"],**limitkey) + "</td>"
|
||||
html += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,**limitkey) + "</td>"
|
||||
html += "</tr>"
|
||||
i += 1
|
||||
html += "</table>"
|
||||
|
||||
replace = {"KEY_PULSE_TABLE":html,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||
|
@ -211,8 +211,16 @@
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
<h1><a href="/pulse?step=month&trail=1">Pulse</a></h1>
|
||||
<!--
|
||||
<a href="/pulse?step=day&trail=1">Days</a>
|
||||
<a href="/pulse?step=week&trail=1">Weeks</a>
|
||||
<a href="/pulse?step=month&trail=1">Months</a>
|
||||
<a href="/pulse?step=year&trail=1">Years</a>
|
||||
-->
|
||||
<br/><br/>
|
||||
<table class='list'>
|
||||
<h1><a href="/pulse?step=month&trail=1">Pulse</a></h1>
|
||||
|
||||
|
||||
<tr>
|
||||
|
@ -24,8 +24,14 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><a href='/pulse?KEY_SCROBBLELINK&step=year&trail=1'>Pulse</a></h2>
|
||||
KEY_PULSE
|
||||
|
||||
|
||||
<h2><a href='/scrobbles?KEY_SCROBBLELINK'>Scrobbles</a></h2>
|
||||
KEY_SCROBBLELIST
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -4,10 +4,11 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo, getTrackInfo
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc, getRangeDesc, scrobblesLink
|
||||
|
||||
clean(keys)
|
||||
limitkeys = pickKeys(keys,"artist","title")
|
||||
trackobject = {"artists":limitkeys.getall("artist"),"title":limitkeys.get("title")}
|
||||
info = getTrackInfo(keys.getall("artist"),keys.get("title"))
|
||||
imgurl = info.get("image")
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
@ -33,8 +34,30 @@ def instructions(keys,dbport):
|
||||
html += "</tr>"
|
||||
html += "</table>"
|
||||
|
||||
|
||||
# pulse
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=year&trail=1&" + keysToUrl(limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
terms = db_data["list"]
|
||||
|
||||
# build list
|
||||
maxbar = max([t["scrobbles"] for t in terms])
|
||||
|
||||
html_pulse = "<table class='list'>"
|
||||
for t in terms:
|
||||
fromstr = "/".join([str(e) for e in t["from"]])
|
||||
tostr = "/".join([str(e) for e in t["to"]])
|
||||
html_pulse += "<tr>"
|
||||
#html += "<td>" + fromstr + "</td>"
|
||||
#html += "<td>" + tostr + "</td>"
|
||||
html_pulse += "<td>" + getRangeDesc(t["from"],t["to"]) + "</td>"
|
||||
html_pulse += "<td class='amount'>" + scrobblesLink({"since":fromstr,"to":tostr},amount=t["scrobbles"],track=trackobject) + "</td>"
|
||||
html_pulse += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,track=trackobject) + "</td>"
|
||||
html_pulse += "</tr>"
|
||||
html_pulse += "</table>"
|
||||
|
||||
|
||||
replace = {"KEY_TRACKTITLE":limitkeys.get("title"),"KEY_ARTISTS":artistLinks(limitkeys.getall("artist")),"KEY_SCROBBLES":scrobblesnum,"KEY_IMAGEURL":imgurl,
|
||||
"KEY_SCROBBLELINK":keysToUrl(limitkeys),"KEY_SCROBBLELIST":html,"KEY_POSITION":pos}
|
||||
"KEY_SCROBBLELINK":keysToUrl(limitkeys),"KEY_SCROBBLELIST":html,"KEY_POSITION":pos,"KEY_PULSE":html_pulse}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
Loading…
Reference in New Issue
Block a user