mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Significant rework of the architecture
* URL keys and internal keys are now being separated more cleanly * HTML generation is split up into submodules that can be used by serveral websites * HTML generation now talks directly to the database in most cases instead of calling the database server for json data
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>KEY_ARTISTNAME</h1> <span class="rank"><a href="/topartists">KEY_POSITION</a></span><br/>
|
||||
<h1>KEY_ARTISTNAME</h1> <span class="rank"><a href="/topartists?max=100">KEY_POSITION</a></span><br/>
|
||||
<span>KEY_ASSOCIATED</span>
|
||||
<p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_SCROBBLES Scrobbles</a></p>
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ import json
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, getRangeDesc, scrobblesLink
|
||||
from htmlmodules import module_pulse, module_trackcharts
|
||||
|
||||
clean(keys)
|
||||
allowedkeys = {"artist":keys.get("artist")}
|
||||
# clean(keys)
|
||||
info = getArtistInfo(keys["artist"])
|
||||
imgurl = info.get("image")
|
||||
#desc = info.get("info")
|
||||
@@ -27,47 +29,12 @@ def instructions(keys,dbport):
|
||||
includestr = "associated: "
|
||||
includestr += artistLinks(included)
|
||||
|
||||
|
||||
|
||||
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/tracks?artist=" + urllib.parse.quote(keys["artist"]))
|
||||
db_data = json.loads(response.read())
|
||||
|
||||
if db_data["list"] != []: maxbar = db_data["list"][0]["scrobbles"]
|
||||
html = "<table class='list'>"
|
||||
for e in db_data["list"]:
|
||||
html += "<tr>"
|
||||
html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
||||
html += "<td>" + trackLink(e["track"]) + "</td>"
|
||||
html += "<td class='amount'>" + scrobblesTrackLink(e["track"],{},amount=e["scrobbles"]) + "</td>"
|
||||
html += "<td class='bar'>" + scrobblesTrackLink(e["track"],{},percent=e["scrobbles"]*100/maxbar) + "</td>"
|
||||
html += "</tr>"
|
||||
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,"KEY_PULSE":html_pulse}
|
||||
html_tracks, _ = module_trackcharts(**allowedkeys)
|
||||
|
||||
|
||||
html_pulse = module_pulse(**allowedkeys,step="year",stepn=1,trail=1)
|
||||
|
||||
replace = {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":"","KEY_TRACKLIST":html_tracks,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr,"KEY_PULSE":html_pulse}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
@@ -4,29 +4,24 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo, getTrackInfo
|
||||
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, pickKeys, clean, getRangeDesc
|
||||
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, getRangeDesc, KeySplit
|
||||
from htmlmodules import module_pulse
|
||||
|
||||
clean(keys)
|
||||
timekeys = pickKeys(keys,"since","to","in","step","trail")
|
||||
limitkeys = pickKeys(keys,"artist","title","associated")
|
||||
filterkeys, timekeys, delimitkeys, _ = KeySplit(keys)
|
||||
|
||||
# Get scrobble data
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?" + keysToUrl(limitkeys,timekeys))
|
||||
db_data = json.loads(response.read())
|
||||
terms = db_data["list"]
|
||||
|
||||
# describe the scope (and creating a key for the relevant artist or track)
|
||||
limitstring = ""
|
||||
limitkey = {}
|
||||
if keys.get("title") is not None:
|
||||
limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")}
|
||||
limitstring += "of " + trackLink(limitkey["track"]) + " "
|
||||
limitstring += "by " + artistLinks(keys.getall("artist"))
|
||||
#limitkey = {}
|
||||
if filterkeys.get("track") is not None:
|
||||
#limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")}
|
||||
limitstring += "of " + trackLink(filterkeys["track"]) + " "
|
||||
limitstring += "by " + artistLinks(filterkeys["track"]["artists"])
|
||||
|
||||
elif keys.get("artist") is not None:
|
||||
limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
||||
limitstring += "of " + artistLink(keys.get("artist"))
|
||||
if keys.get("associated") is not None:
|
||||
elif filterkeys.get("artist") is not None:
|
||||
#limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
||||
limitstring += "of " + artistLink(filterkeys.get("artist"))
|
||||
if filterkeys.get("associated"):
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/artistinfo?artist=" + urllib.parse.quote(keys["artist"]))
|
||||
db_data = json.loads(response.read())
|
||||
moreartists = db_data["associated"]
|
||||
@@ -35,9 +30,9 @@ def instructions(keys,dbport):
|
||||
|
||||
|
||||
# get image
|
||||
if limitkeys.get("title") is not None:
|
||||
imgurl = getTrackInfo(limitkeys.getall("artist"),limitkeys.get("title")).get("image")
|
||||
elif keys.get("artist") is not None:
|
||||
if filterkeys.get("track") is not None:
|
||||
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
||||
elif filterkeys.get("artist") is not None:
|
||||
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
||||
#elif (len(scrobbles) != 0):
|
||||
# imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
||||
@@ -49,23 +44,9 @@ def instructions(keys,dbport):
|
||||
|
||||
|
||||
|
||||
# build list
|
||||
maxbar = max([t["scrobbles"] for t in terms])
|
||||
html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys)
|
||||
|
||||
html = "<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 += "<tr>"
|
||||
#html += "<td>" + fromstr + "</td>"
|
||||
#html += "<td>" + tostr + "</td>"
|
||||
html += "<td>" + getRangeDesc(t["from"],t["to"]) + "</td>"
|
||||
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>"
|
||||
html += "</table>"
|
||||
|
||||
replace = {"KEY_PULSE_TABLE":html,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||
replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
|
||||
@@ -4,16 +4,11 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo, getTrackInfo
|
||||
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, keysToUrl, pickKeys, clean
|
||||
from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, keysToUrl, KeySplit
|
||||
from htmlmodules import module_scrobblelist
|
||||
|
||||
clean(keys)
|
||||
timekeys = pickKeys(keys,"since","to","in","max")
|
||||
limitkeys = pickKeys(keys,"artist","title","associated")
|
||||
|
||||
# Get scrobble data
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys,timekeys))
|
||||
db_data = json.loads(response.read())
|
||||
scrobbles = db_data["list"]
|
||||
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
||||
|
||||
# describe the scope
|
||||
limitstring = ""
|
||||
@@ -30,33 +25,25 @@ def instructions(keys,dbport):
|
||||
if moreartists != []:
|
||||
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
||||
|
||||
|
||||
|
||||
html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys)
|
||||
|
||||
# get image
|
||||
if limitkeys.get("title") is not None:
|
||||
imgurl = getTrackInfo(limitkeys.getall("artist"),limitkeys.get("title")).get("image")
|
||||
elif keys.get("artist") is not None:
|
||||
if filterkeys.get("track") is not None:
|
||||
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
||||
elif filterkeys.get("artist") is not None:
|
||||
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
||||
elif (len(scrobbles) != 0):
|
||||
imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
||||
#imgurl = getArtistInfo(scrobbles[0]["artists"][0]).get("image")
|
||||
elif rep is not None:
|
||||
imgurl = getTrackInfo(rep["artists"],rep["title"]).get("image")
|
||||
else:
|
||||
imgurl = ""
|
||||
|
||||
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
|
||||
# build list
|
||||
html = "<table class='list'>"
|
||||
for s in scrobbles:
|
||||
html += "<tr>"
|
||||
html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
||||
#html += """<td class='icon' style="background-image:url('""" + getArtistInfo(s["artists"][0]).get("image") + """')" /></td>"""
|
||||
html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
||||
html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
||||
html += "</tr>"
|
||||
html += "</table>"
|
||||
|
||||
replace = {"KEY_SCROBBLELIST":html,"KEY_SCROBBLES":str(len(scrobbles)),"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||
replace = {"KEY_SCROBBLELIST":html,"KEY_SCROBBLES":str(amount),"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1><a href="/topartists">Top Artists</a></h1>
|
||||
<h1><a href="/topartists?max=50">Top Artists</a></h1>
|
||||
<table class="tiles_top">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
|
||||
|
||||
<h1><a href="/toptracks">Top Tracks</a></h1>
|
||||
<h1><a href="/toptracks?max=50">Top Tracks</a></h1>
|
||||
<table class="tiles_top">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -116,98 +116,9 @@
|
||||
<span class="stats">This year</span> KEY_SCROBBLES_YEAR
|
||||
<span class="stats">All Time</span> KEY_SCROBBLES_TOTAL
|
||||
<br/><br/>
|
||||
<table class='list'>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='time'>KEY_SCROBBLE_TIME</td>
|
||||
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
|
||||
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
|
||||
<td class='title'>KEY_SCROBBLE_TITLE</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
KEY_SCROBBLES
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
@@ -220,70 +131,9 @@
|
||||
<a href="/pulse?step=year&trail=1">Years</a>
|
||||
-->
|
||||
<br/><br/>
|
||||
<table class='list'>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>KEY_PULSE_TERM</td>
|
||||
<td class='amount'>KEY_PULSE_AMOUNT</td>
|
||||
<td class='bar'>KEY_PULSE_BAR</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
KEY_PULSE
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ from threading import Thread
|
||||
from datetime import datetime
|
||||
#import database
|
||||
|
||||
from htmlmodules import module_scrobblelist, module_pulse
|
||||
|
||||
|
||||
def getpictures(ls,result,tracks=False):
|
||||
from utilities import getArtistsInfo, getTracksInfo
|
||||
@@ -60,19 +62,21 @@ def instructions(keys,dbport):
|
||||
|
||||
|
||||
# get scrobbles
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?max=50")
|
||||
db_data = json.loads(response.read())
|
||||
scrobblelist = db_data["list"]
|
||||
#scrobblelist = database.get_scrobbles(max=50)
|
||||
scrobbletrackobjects = scrobblelist #ignore the extra time attribute, the format should still work
|
||||
scrobbleartists = [", ".join([artistLink(a) for a in s["artists"]]) for s in scrobblelist]
|
||||
scrobbletitles = [s["title"] for s in scrobblelist]
|
||||
scrobbletimes = [getTimeDesc(s["time"],short=True) for s in scrobblelist]
|
||||
scrobbleimages = []
|
||||
t3 = Thread(target=getpictures,args=(scrobbletrackobjects,scrobbleimages,),kwargs={"tracks":True})
|
||||
t3.start()
|
||||
#scrobbleimages = [info.get("image") for info in getTracksInfo(scrobbletrackobjects)]
|
||||
scrobbletracklinks = [trackLink(t) for t in scrobbletrackobjects]
|
||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?max=50")
|
||||
# db_data = json.loads(response.read())
|
||||
# scrobblelist = db_data["list"]
|
||||
# #scrobblelist = database.get_scrobbles(max=50)
|
||||
# scrobbletrackobjects = scrobblelist #ignore the extra time attribute, the format should still work
|
||||
# scrobbleartists = [", ".join([artistLink(a) for a in s["artists"]]) for s in scrobblelist]
|
||||
# scrobbletitles = [s["title"] for s in scrobblelist]
|
||||
# scrobbletimes = [getTimeDesc(s["time"],short=True) for s in scrobblelist]
|
||||
# scrobbleimages = []
|
||||
# t3 = Thread(target=getpictures,args=(scrobbletrackobjects,scrobbleimages,),kwargs={"tracks":True})
|
||||
# t3.start()
|
||||
# #scrobbleimages = [info.get("image") for info in getTracksInfo(scrobbletrackobjects)]
|
||||
# scrobbletracklinks = [trackLink(t) for t in scrobbletrackobjects]
|
||||
|
||||
html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True)
|
||||
|
||||
|
||||
# get stats
|
||||
@@ -101,33 +105,36 @@ def instructions(keys,dbport):
|
||||
# this is literally the ugliest piece of code i have written in my entire feckin life
|
||||
# good lord
|
||||
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=month&trail=1&since=" + dts)
|
||||
db_data = json.loads(response.read())
|
||||
terms = db_data["list"]
|
||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=month&trail=1&since=" + dts)
|
||||
# db_data = json.loads(response.read())
|
||||
# terms = db_data["list"]
|
||||
|
||||
maxbar = max([t["scrobbles"] for t in terms])
|
||||
#pulse_fromdates = ["/".join([str(e) for e in t["from"]]) for t in terms]
|
||||
#pulse_todates = ["/".join([str(e) for e in t["to"]]) for t in terms]
|
||||
pulse_rangedescs = [getRangeDesc(t["from"],t["to"]) for t in terms]
|
||||
pulse_amounts = [scrobblesLink({"since":"/".join([str(e) for e in t["from"]]),"to":"/".join([str(e) for e in t["to"]])},amount=t["scrobbles"]) for t in terms]
|
||||
pulse_bars = [scrobblesLink({"since":"/".join([str(e) for e in t["from"]]),"to":"/".join([str(e) for e in t["to"]])},percent=t["scrobbles"]*100/maxbar) for t in terms]
|
||||
|
||||
# maxbar = max([t["scrobbles"] for t in terms])
|
||||
# #pulse_fromdates = ["/".join([str(e) for e in t["from"]]) for t in terms]
|
||||
# #pulse_todates = ["/".join([str(e) for e in t["to"]]) for t in terms]
|
||||
# pulse_rangedescs = [getRangeDesc(t["from"],t["to"]) for t in terms]
|
||||
# pulse_amounts = [scrobblesLink({"since":"/".join([str(e) for e in t["from"]]),"to":"/".join([str(e) for e in t["to"]])},amount=t["scrobbles"]) for t in terms]
|
||||
# pulse_bars = [scrobblesLink({"since":"/".join([str(e) for e in t["from"]]),"to":"/".join([str(e) for e in t["to"]])},percent=t["scrobbles"]*100/maxbar) for t in terms]
|
||||
|
||||
html_pulse = module_pulse(max_=12,since=dts,step="month",trail=1)
|
||||
|
||||
|
||||
|
||||
t1.join()
|
||||
t2.join()
|
||||
t3.join()
|
||||
#t3.join()
|
||||
|
||||
pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages + scrobbleimages if img.startswith("/")]
|
||||
|
||||
#pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages + scrobbleimages if img.startswith("/")]
|
||||
pushresources = []
|
||||
|
||||
replace = {"KEY_ARTISTIMAGE":artistimages,"KEY_ARTISTNAME":artisttitles,"KEY_ARTISTLINK":artistlinks,"KEY_POSITION_ARTIST":posrange,
|
||||
"KEY_TRACKIMAGE":trackimages,"KEY_TRACKNAME":tracktitles,"KEY_TRACKLINK":tracklinks,"KEY_POSITION_TRACK":posrange,
|
||||
"KEY_SCROBBLES_TODAY":scrobbles_today,"KEY_SCROBBLES_MONTH":scrobbles_month,"KEY_SCROBBLES_YEAR":scrobbles_year,"KEY_SCROBBLES_TOTAL":scrobbles_total,
|
||||
"KEY_SCROBBLE_TIME":scrobbletimes,"KEY_SCROBBLE_ARTISTS":scrobbleartists,"KEY_SCROBBLE_TITLE":scrobbletracklinks,"KEY_SCROBBLE_IMAGE":scrobbleimages,
|
||||
"KEY_PULSE_TERM":pulse_rangedescs,"KEY_PULSE_AMOUNT":pulse_amounts,"KEY_PULSE_BAR":pulse_bars}
|
||||
#"KEY_SCROBBLE_TIME":scrobbletimes,"KEY_SCROBBLE_ARTISTS":scrobbleartists,"KEY_SCROBBLE_TITLE":scrobbletracklinks,"KEY_SCROBBLE_IMAGE":scrobbleimages,
|
||||
"KEY_SCROBBLES":html_scrobbles,
|
||||
#"KEY_PULSE_TERM":pulse_rangedescs,"KEY_PULSE_AMOUNT":pulse_amounts,"KEY_PULSE_BAR":pulse_bars
|
||||
"KEY_PULSE":html_pulse
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<td class="text">
|
||||
<h1>Top Artists</h1><br/>
|
||||
<span>in KEY_RANGE</span>
|
||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -4,47 +4,60 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo
|
||||
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, keysToUrl, pickKeys, clean
|
||||
from htmlgenerators import KeySplit
|
||||
from htmlmodules import module_artistcharts
|
||||
|
||||
clean(keys)
|
||||
timekeys = pickKeys(keys,"since","to","in")
|
||||
limitkeys = pickKeys(keys)
|
||||
# clean(keys)
|
||||
# timekeys = pickKeys(keys,"since","to","in")
|
||||
# limitkeys = pickKeys(keys)
|
||||
|
||||
_, timekeys, _, amountkeys = KeySplit(keys)
|
||||
|
||||
# get chart data
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
charts = db_data["list"][:50]
|
||||
topartist = charts[0]["artist"]
|
||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
||||
# db_data = json.loads(response.read())
|
||||
# charts = db_data["list"][:50]
|
||||
# topartist = charts[0]["artist"]
|
||||
|
||||
# info = getArtistInfo(topartist)
|
||||
# imgurl = info.get("image")
|
||||
|
||||
info = getArtistInfo(topartist)
|
||||
imgurl = info.get("image")
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
# get total amount of scrobbles
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
scrobblelist = db_data["list"]
|
||||
scrobbles = len(scrobblelist)
|
||||
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||
#db_data = json.loads(response.read())
|
||||
#scrobblelist = db_data["list"]
|
||||
#scrobbles = len(scrobblelist)
|
||||
|
||||
|
||||
html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
|
||||
|
||||
if rep is not None:
|
||||
imgurl = getArtistInfo(rep).get("image")
|
||||
else:
|
||||
imgurl = ""
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
# build list
|
||||
maxbar = charts[0]["scrobbles"]
|
||||
|
||||
i = 1
|
||||
html = "<table class='list'>"
|
||||
for e in charts:
|
||||
html += "<tr>"
|
||||
html += "<td class='rank'>#" + str(i) + "</td>"
|
||||
html += "<td class='artist'>" + artistLink(e["artist"])
|
||||
if (e["counting"] != []):
|
||||
html += " <span class='extra'>incl. " + ", ".join([artistLink(a) for a in e["counting"]]) + "</span>"
|
||||
html += "</td>"
|
||||
html += "<td class='amount'>" + scrobblesArtistLink(e["artist"],timekeys,amount=e["scrobbles"],associated=True) + "</td>"
|
||||
html += "<td class='bar'>" + scrobblesArtistLink(e["artist"],timekeys,percent=e["scrobbles"]*100/maxbar,associated=True) + "</td>"
|
||||
html += "</tr>"
|
||||
i += 1
|
||||
html += "</table>"
|
||||
# maxbar = charts[0]["scrobbles"]
|
||||
#
|
||||
# i = 1
|
||||
# html = "<table class='list'>"
|
||||
# for e in charts:
|
||||
# html += "<tr>"
|
||||
# html += "<td class='rank'>#" + str(i) + "</td>"
|
||||
# html += "<td class='artist'>" + artistLink(e["artist"])
|
||||
# if (e["counting"] != []):
|
||||
# html += " <span class='extra'>incl. " + ", ".join([artistLink(a) for a in e["counting"]]) + "</span>"
|
||||
# html += "</td>"
|
||||
# html += "<td class='amount'>" + scrobblesArtistLink(e["artist"],timekeys,amount=e["scrobbles"],associated=True) + "</td>"
|
||||
# html += "<td class='bar'>" + scrobblesArtistLink(e["artist"],timekeys,percent=e["scrobbles"]*100/maxbar,associated=True) + "</td>"
|
||||
# html += "</tr>"
|
||||
# i += 1
|
||||
# html += "</table>"
|
||||
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_ARTISTLIST":html}
|
||||
|
||||
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<td class="text">
|
||||
<h1>Top Tracks</h1><br/>
|
||||
<span>KEY_LIMITS</span>
|
||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -4,57 +4,70 @@ import json
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo, getTrackInfo
|
||||
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, clean
|
||||
from htmlgenerators import artistLink, KeySplit
|
||||
from htmlmodules import module_trackcharts
|
||||
|
||||
clean(keys)
|
||||
timekeys = pickKeys(keys,"since","to","in")
|
||||
limitkeys = pickKeys(keys,"artist")
|
||||
# clean(keys)
|
||||
# timekeys = pickKeys(keys,"since","to","in")
|
||||
# limitkeys = pickKeys(keys,"artist")
|
||||
|
||||
# get chart data
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/tracks?" + keysToUrl(timekeys,limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
charts = db_data["list"][:50]
|
||||
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
||||
|
||||
|
||||
limitstring = ""
|
||||
|
||||
if keys.get("artist") is not None:
|
||||
topartist = keys.get("artist")
|
||||
#limitstring += "by " + ", ".join([artistLink(a) for a in keys.getall("artist")])
|
||||
limitstring = "by " + artistLink(keys.get("artist"))
|
||||
info = getArtistInfo(topartist)
|
||||
imgurl = info.get("image")
|
||||
else:
|
||||
#topartist = charts[0]["track"]["artists"][0] #for now
|
||||
info = getTrackInfo(charts[0]["track"]["artists"],charts[0]["track"]["title"])
|
||||
imgurl = info.get("image")
|
||||
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
if filterkeys.get("artist") is not None:
|
||||
topartist = filterkeys.get("artist")
|
||||
# #limitstring += "by " + ", ".join([artistLink(a) for a in keys.getall("artist")])
|
||||
limitstring = "by " + artistLink(filterkeys.get("artist"))
|
||||
# info = getArtistInfo(topartist)
|
||||
# imgurl = info.get("image")
|
||||
# else:
|
||||
# #topartist = charts[0]["track"]["artists"][0] #for now
|
||||
# info = getTrackInfo(charts[0]["track"]["artists"],charts[0]["track"]["title"])
|
||||
# imgurl = info.get("image")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# get total amount of scrobbles
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
scrobblelist = db_data["list"]
|
||||
scrobbles = len(scrobblelist)
|
||||
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||
# db_data = json.loads(response.read())
|
||||
# scrobblelist = db_data["list"]
|
||||
# scrobbles = len(scrobblelist)
|
||||
|
||||
|
||||
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
|
||||
|
||||
|
||||
if filterkeys.get("artist") is not None:
|
||||
imgurl = getArtistInfo(filterkeys.get("artist")).get("image")
|
||||
limitstring = "by " + artistLink(filterkeys.get("artist"))
|
||||
elif rep is not None:
|
||||
imgurl = getTrackInfo(rep["artists"],rep["title"]).get("image")
|
||||
else:
|
||||
imgurl = ""
|
||||
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
# build list
|
||||
maxbar = charts[0]["scrobbles"]
|
||||
|
||||
i = 1
|
||||
html = "<table class='list'>"
|
||||
for e in charts:
|
||||
html += "<tr>"
|
||||
html += "<td class='rank'>#" + str(i) + "</td>"
|
||||
html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
||||
html += "<td class='title'>" + trackLink(e["track"]) + "</td>"
|
||||
html += "<td class='amount'>" + scrobblesTrackLink(e["track"],timekeys,amount=e["scrobbles"]) + "</td>"
|
||||
html += "<td class='bar'>" + scrobblesTrackLink(e["track"],timekeys,percent=e["scrobbles"]*100/maxbar) + "</td>"
|
||||
html += "</tr>"
|
||||
i += 1
|
||||
html += "</table>"
|
||||
# maxbar = charts[0]["scrobbles"]
|
||||
#
|
||||
# i = 1
|
||||
# html = "<table class='list'>"
|
||||
# for e in charts:
|
||||
# html += "<tr>"
|
||||
# html += "<td class='rank'>#" + str(i) + "</td>"
|
||||
# html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
||||
# html += "<td class='title'>" + trackLink(e["track"]) + "</td>"
|
||||
# html += "<td class='amount'>" + scrobblesTrackLink(e["track"],timekeys,amount=e["scrobbles"]) + "</td>"
|
||||
# html += "<td class='bar'>" + scrobblesTrackLink(e["track"],timekeys,percent=e["scrobbles"]*100/maxbar) + "</td>"
|
||||
# html += "</tr>"
|
||||
# i += 1
|
||||
# html += "</table>"
|
||||
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_TRACKLIST":html,"KEY_LIMITS":limitstring}
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</td>
|
||||
<td class="text">
|
||||
<span>KEY_ARTISTS</span><br/>
|
||||
<h1>KEY_TRACKTITLE</h1> <span class="rank"><a href="/toptracks">KEY_POSITION</a></span>
|
||||
<h1>KEY_TRACKTITLE</h1> <span class="rank"><a href="/toptracks?max=100">KEY_POSITION</a></span>
|
||||
|
||||
<p class="stats"><a href="/scrobbles?KEY_SCROBBLELINK">KEY_SCROBBLES Scrobbles</a></p>
|
||||
|
||||
|
||||
@@ -1,63 +1,67 @@
|
||||
import urllib
|
||||
import json
|
||||
import database
|
||||
|
||||
|
||||
def instructions(keys,dbport):
|
||||
from utilities import getArtistInfo, getTrackInfo
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc, getRangeDesc, scrobblesLink
|
||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc, getRangeDesc, scrobblesLink, KeySplit
|
||||
from htmlmodules import module_scrobblelist, module_pulse
|
||||
|
||||
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")
|
||||
|
||||
filterkeys, _, _, _ = KeySplit(keys)
|
||||
|
||||
track = filterkeys.get("track")
|
||||
imgurl = getTrackInfo(track["artists"],track["title"]).get("image")
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/trackinfo?" + keysToUrl(limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
scrobblesnum = str(db_data["scrobbles"])
|
||||
pos = "#" + str(db_data["position"])
|
||||
data = database.trackInfo(track["artists"],track["title"])
|
||||
scrobblesnum = str(data["scrobbles"])
|
||||
pos = "#" + str(data["position"])
|
||||
|
||||
|
||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys))
|
||||
db_data = json.loads(response.read())
|
||||
scrobbles = db_data["list"]
|
||||
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys))
|
||||
#db_data = json.loads(response.read())
|
||||
#scrobbles = db_data["list"]
|
||||
|
||||
|
||||
# build list
|
||||
html = "<table class='list'>"
|
||||
for s in scrobbles:
|
||||
html += "<tr>"
|
||||
html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
||||
html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
||||
html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
||||
html += "</tr>"
|
||||
html += "</table>"
|
||||
|
||||
# html = "<table class='list'>"
|
||||
# for s in scrobbles:
|
||||
# html += "<tr>"
|
||||
# html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
||||
# html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
||||
# html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
||||
# html += "</tr>"
|
||||
# html += "</table>"
|
||||
|
||||
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100)
|
||||
|
||||
# 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"]
|
||||
# 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])
|
||||
# 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>"
|
||||
# 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>"
|
||||
|
||||
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
|
||||
|
||||
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_PULSE":html_pulse}
|
||||
|
||||
replace = {"KEY_TRACKTITLE":track.get("title"),"KEY_ARTISTS":artistLinks(track.get("artists")),"KEY_SCROBBLES":scrobblesnum,"KEY_IMAGEURL":imgurl,
|
||||
"KEY_SCROBBLELINK":keysToUrl(keys),"KEY_SCROBBLELIST":html_scrobbles,"KEY_POSITION":pos,"KEY_PULSE":html_pulse}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
||||
Reference in New Issue
Block a user