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:
parent
a4b95969d5
commit
5f19e7b38e
39
database.py
39
database.py
@ -158,17 +158,17 @@ def get_scrobbles_external():
|
|||||||
ckeys["artists"], ckeys["title"] = keys.getall("artist"), keys.get("title")
|
ckeys["artists"], ckeys["title"] = keys.getall("artist"), keys.get("title")
|
||||||
ckeys["since"], ckeys["to"], ckeys["within"] = keys.get("since"), keys.get("to"), keys.get("in")
|
ckeys["since"], ckeys["to"], ckeys["within"] = keys.get("since"), keys.get("to"), keys.get("in")
|
||||||
ckeys["associated"] = (keys.get("associated")!=None)
|
ckeys["associated"] = (keys.get("associated")!=None)
|
||||||
ckeys["max"] = keys.get("max")
|
ckeys["max_"] = keys.get("max")
|
||||||
|
|
||||||
result = get_scrobbles(**ckeys)
|
result = get_scrobbles(**ckeys)
|
||||||
return {"list":result}
|
return {"list":result}
|
||||||
|
|
||||||
def get_scrobbles(**keys):
|
def get_scrobbles(**keys):
|
||||||
r = db_query(**{k:keys[k] for k in keys if k in ["artists","title","since","to","within","associated"]})
|
r = db_query(**{k:keys[k] for k in keys if k in ["artist","artists","title","since","to","within","associated","track"]})
|
||||||
r.reverse()
|
r.reverse()
|
||||||
|
|
||||||
if keys.get("max") is not None:
|
if keys.get("max_") is not None:
|
||||||
return r[:int(keys.get("max"))]
|
return r[:int(keys.get("max_"))]
|
||||||
else:
|
else:
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ def get_pulse(step="month",stepn=1,trail=3,**keys):
|
|||||||
#d_current_end = getNext(d_current,step,stepn * trail)
|
#d_current_end = getNext(d_current,step,stepn * trail)
|
||||||
d_current_end = getEnd(d_current,step,stepn * trail)
|
d_current_end = getEnd(d_current,step,stepn * trail)
|
||||||
#res = db_aggregate(since=d_current,to=d_current_end)
|
#res = db_aggregate(since=d_current,to=d_current_end)
|
||||||
res = len(db_query(since=d_current,to=d_current_end,**{k:keys[k] for k in keys if k in ["artists","title","associated"]}))
|
res = len(db_query(since=d_current,to=d_current_end,**{k:keys[k] for k in keys if k in ["artists","artist","track","title","associated"]}))
|
||||||
results.append({"from":d_current,"to":d_current_end,"scrobbles":res})
|
results.append({"from":d_current,"to":d_current_end,"scrobbles":res})
|
||||||
d_current = getNext(d_current,step,stepn)
|
d_current = getNext(d_current,step,stepn)
|
||||||
if isPast(d_current_end,d_end):
|
if isPast(d_current_end,d_end):
|
||||||
@ -841,17 +841,35 @@ def sync():
|
|||||||
|
|
||||||
|
|
||||||
# Queries the database
|
# Queries the database
|
||||||
def db_query(artists=None,title=None,track=None,since=None,to=None,within=None,associated=False):
|
def db_query(artist=None,artists=None,title=None,track=None,since=None,to=None,within=None,associated=False):
|
||||||
|
# print(artists)
|
||||||
|
# print(title)
|
||||||
|
# print(track)
|
||||||
|
# print(since)
|
||||||
|
# print(to)
|
||||||
|
# print(within)
|
||||||
|
# print(associated)
|
||||||
|
|
||||||
(since, to) = getTimestamps(since,to,within)
|
(since, to) = getTimestamps(since,to,within)
|
||||||
|
|
||||||
# this is not meant as a search function. we *can* query the db with a string, but it only works if it matches exactly
|
# this is not meant as a search function. we *can* query the db with a string, but it only works if it matches exactly
|
||||||
# if a title is specified, we assume that a specific track (with the exact artist combination) is requested
|
# if a title is specified, we assume that a specific track (with the exact artist combination) is requested
|
||||||
# if not, duplicate artist arguments are ignored
|
# if not, duplicate artist arguments are ignored
|
||||||
|
|
||||||
artist = None
|
#artist = None
|
||||||
|
|
||||||
# artists to numbers
|
if artist is not None and isinstance(artist,str):
|
||||||
artists = set([(ARTISTS.index(a) if isinstance(a,str) else a) for a in artists])
|
artist = ARTISTS.index(artist)
|
||||||
|
|
||||||
|
# artists to numbers
|
||||||
|
if artists is not None:
|
||||||
|
artists = set([(ARTISTS.index(a) if isinstance(a,str) else a) for a in artists])
|
||||||
|
|
||||||
|
# track to number
|
||||||
|
if track is not None and isinstance(track,dict):
|
||||||
|
trackartists = set([(ARTISTS.index(a) if isinstance(a,str) else a) for a in track["artists"]])
|
||||||
|
track = TRACKS.index((frozenset(trackartists),track["title"]))
|
||||||
|
artists = None
|
||||||
|
|
||||||
#check if track is requested via title
|
#check if track is requested via title
|
||||||
if title!=None and track==None:
|
if title!=None and track==None:
|
||||||
@ -860,8 +878,9 @@ def db_query(artists=None,title=None,track=None,since=None,to=None,within=None,a
|
|||||||
|
|
||||||
# if we're not looking for a track (either directly or per title artist arguments, which is converted to track above)
|
# if we're not looking for a track (either directly or per title artist arguments, which is converted to track above)
|
||||||
# we only need one artist
|
# we only need one artist
|
||||||
elif track==None and len(artists) != 0:
|
elif artist is None and track is None and artists is not None and len(artists) != 0:
|
||||||
artist = artists.pop()
|
artist = artists.pop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# right now we always request everything by name, maybe we don't actually need the request by number, but i'll leave it in for now
|
# right now we always request everything by name, maybe we don't actually need the request by number, but i'll leave it in for now
|
||||||
|
@ -108,6 +108,71 @@ def getRangeDesc(timeA,timeB,inclusiveB=True):
|
|||||||
|
|
||||||
return getTimeDesc(timeA) + " to " + getTimeDesc(timeB)
|
return getTimeDesc(timeA) + " to " + getTimeDesc(timeB)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# finds out if we want an artist or a track
|
||||||
|
#def interpretURLKeys(keys):
|
||||||
|
# if "title" in keys:
|
||||||
|
# return {"track":{"artists":keys.getall("artist"),"title":keys.get("title")}}
|
||||||
|
# if "artist" in keys:
|
||||||
|
# return {"artist":keys.get("artist")}
|
||||||
|
#
|
||||||
|
# return {}
|
||||||
|
|
||||||
|
# alright this is the last one
|
||||||
|
# one ultimate method to rule them all
|
||||||
|
# one method to take html keys and convert them into internal keys
|
||||||
|
# it renames them, interprets what's being asked, removes duplicates
|
||||||
|
# it gets rid of multidicts
|
||||||
|
# it does fecking everything
|
||||||
|
# it's the best
|
||||||
|
# fantastic
|
||||||
|
def KeySplit(keys):
|
||||||
|
|
||||||
|
# output:
|
||||||
|
# 1 keys that define the filtered object like artist or track
|
||||||
|
# 2 keys that define time limits of the whole thing
|
||||||
|
# 3 keys that define interal time ranges
|
||||||
|
# 4 keys that define amount limits
|
||||||
|
|
||||||
|
# 1
|
||||||
|
if "title" in keys:
|
||||||
|
resultkeys1 = {"track":{"artists":keys.getall("artist"),"title":keys.get("title")}}
|
||||||
|
elif "artist" in keys:
|
||||||
|
resultkeys1 = {"artist":keys.get("artist")}
|
||||||
|
if "associated" in keys: resultkeys1["associated"] = True
|
||||||
|
else:
|
||||||
|
resultkeys1 = {}
|
||||||
|
|
||||||
|
# 2
|
||||||
|
resultkeys2 = {}
|
||||||
|
if "since" in keys: resultkeys2["since"] = keys.get("since")
|
||||||
|
elif "from" in keys: resultkeys2["since"] = keys.get("from")
|
||||||
|
elif "start" in keys: resultkeys2["since"] = keys.get("start")
|
||||||
|
#
|
||||||
|
if "to" in keys: resultkeys2["to"] = keys.get("to")
|
||||||
|
elif "until" in keys: resultkeys2["to"] = keys.get("until")
|
||||||
|
elif "end" in keys: resultkeys2["to"] = keys.get("end")
|
||||||
|
#
|
||||||
|
if "in" in keys: resultkeys2["within"] = keys.get("in")
|
||||||
|
elif "within" in keys: resultkeys2["within"] = keys.get("within")
|
||||||
|
elif "during" in keys: resultkeys2["within"] = keys.get("during")
|
||||||
|
|
||||||
|
|
||||||
|
#3
|
||||||
|
resultkeys3 = {}
|
||||||
|
if "step" in keys: [resultkeys3["step"],resultkeys3["stepn"]] = (keys["step"].split("-") + [1])[:2]
|
||||||
|
if "stepn" in keys: resultkeys3["stepn"] = keys["stepn"] #overwrite if explicitly given
|
||||||
|
if "stepn" in resultkeys3: resultkeys3["stepn"] = int(resultkeys3["stepn"]) #in both cases, convert it here
|
||||||
|
if "trail" in keys: resultkeys3["trail"] = int(keys["trail"])
|
||||||
|
|
||||||
|
|
||||||
|
#4
|
||||||
|
resultkeys4 = {}
|
||||||
|
if "max" in keys: resultkeys4["max_"] = int(keys["max"])
|
||||||
|
|
||||||
|
return resultkeys1, resultkeys2, resultkeys3, resultkeys4
|
||||||
|
|
||||||
|
|
||||||
# limit a multidict to only the specified keys
|
# limit a multidict to only the specified keys
|
||||||
# would be a simple constructor expression, but multidicts apparently don't let me do that
|
# would be a simple constructor expression, but multidicts apparently don't let me do that
|
||||||
|
140
htmlmodules.py
Normal file
140
htmlmodules.py
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
from htmlgenerators import *
|
||||||
|
import database
|
||||||
|
from utilities import getArtistsInfo, getTracksInfo
|
||||||
|
|
||||||
|
|
||||||
|
def getpictures(ls,result,tracks=False):
|
||||||
|
from utilities import getArtistsInfo, getTracksInfo
|
||||||
|
if tracks:
|
||||||
|
for element in getTracksInfo(ls):
|
||||||
|
result.append(element.get("image"))
|
||||||
|
else:
|
||||||
|
for element in getArtistsInfo(ls):
|
||||||
|
result.append(element.get("image"))
|
||||||
|
|
||||||
|
|
||||||
|
# artist=None,track=None,since=None,to=None,within=None,associated=False,max_=None,pictures=False
|
||||||
|
def module_scrobblelist(max_=None,pictures=False,shortTimeDesc=False,**kwargs):
|
||||||
|
|
||||||
|
kwargs_filter = pickKeys(kwargs,"artist","track","associated")
|
||||||
|
kwargs_time = pickKeys(kwargs,"since","to","within")
|
||||||
|
|
||||||
|
scrobbles = database.get_scrobbles(**kwargs_time,**kwargs_filter) #we're getting all scrobbles for the number and only filtering them on site
|
||||||
|
if pictures:
|
||||||
|
scrobbleswithpictures = scrobbles if max_ is None else scrobbles[:max_]
|
||||||
|
scrobbleimages = [e.get("image") for e in getTracksInfo(scrobbleswithpictures)] #will still work with scrobble objects as they are a technically a subset of track objects
|
||||||
|
|
||||||
|
representative = scrobbles[0] if scrobbles is not [] else None
|
||||||
|
|
||||||
|
# build list
|
||||||
|
i = 0
|
||||||
|
html = "<table class='list'>"
|
||||||
|
for s in scrobbles:
|
||||||
|
i += 1
|
||||||
|
if max_ is not None and i>=max_:
|
||||||
|
break
|
||||||
|
|
||||||
|
html += "<tr>"
|
||||||
|
html += "<td class='time'>" + getTimeDesc(s["time"],short=shortTimeDesc) + "</td>"
|
||||||
|
if pictures:
|
||||||
|
html += """<td class='icon'><div style="background-image:url('""" + scrobbleimages[i] + """')"></div></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>"
|
||||||
|
|
||||||
|
return (html,len(scrobbles),representative)
|
||||||
|
|
||||||
|
|
||||||
|
def module_pulse(max_=None,**kwargs):
|
||||||
|
|
||||||
|
kwargs_filter = pickKeys(kwargs,"artist","track","associated")
|
||||||
|
kwargs_time = pickKeys(kwargs,"since","to","within","step","stepn","trail")
|
||||||
|
|
||||||
|
ranges = database.get_pulse(**kwargs_time,**kwargs_filter)
|
||||||
|
|
||||||
|
maxbar = max([t["scrobbles"] for t in ranges])
|
||||||
|
maxbar = max(maxbar,1)
|
||||||
|
|
||||||
|
#build list
|
||||||
|
html = "<table class='list'>"
|
||||||
|
for t in ranges:
|
||||||
|
fromstr = "/".join([str(e) for e in t["from"]])
|
||||||
|
tostr = "/".join([str(e) for e in t["to"]])
|
||||||
|
html += "<tr>"
|
||||||
|
html += "<td>" + getRangeDesc(t["from"],t["to"]) + "</td>"
|
||||||
|
html += "<td class='amount'>" + scrobblesLink({"since":fromstr,"to":tostr},amount=t["scrobbles"],**kwargs_filter) + "</td>"
|
||||||
|
html += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,**kwargs_filter) + "</td>"
|
||||||
|
html += "</tr>"
|
||||||
|
html += "</table>"
|
||||||
|
|
||||||
|
|
||||||
|
return html
|
||||||
|
|
||||||
|
def module_trackcharts(max_=None,**kwargs):
|
||||||
|
|
||||||
|
kwargs_filter = pickKeys(kwargs,"artist","associated")
|
||||||
|
kwargs_time = pickKeys(kwargs,"since","to","within")
|
||||||
|
|
||||||
|
tracks = database.get_charts_tracks(**kwargs_filter,**kwargs_time)
|
||||||
|
|
||||||
|
if tracks != []:
|
||||||
|
maxbar = tracks[0]["scrobbles"]
|
||||||
|
representative = tracks[0]["track"]
|
||||||
|
else:
|
||||||
|
representative = None
|
||||||
|
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
html = "<table class='list'>"
|
||||||
|
for e in tracks:
|
||||||
|
i += 1
|
||||||
|
if max_ is not None and i>max_:
|
||||||
|
break
|
||||||
|
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"],kwargs_time,amount=e["scrobbles"]) + "</td>"
|
||||||
|
html += "<td class='bar'>" + scrobblesTrackLink(e["track"],kwargs_time,percent=e["scrobbles"]*100/maxbar) + "</td>"
|
||||||
|
html += "</tr>"
|
||||||
|
html += "</table>"
|
||||||
|
|
||||||
|
return (html,representative)
|
||||||
|
|
||||||
|
|
||||||
|
def module_artistcharts(max_=None,**kwargs):
|
||||||
|
|
||||||
|
kwargs_filter = pickKeys(kwargs,"associated") #not used right now
|
||||||
|
kwargs_time = pickKeys(kwargs,"since","to","within")
|
||||||
|
|
||||||
|
artists = database.get_charts_artists(**kwargs_filter,**kwargs_time)
|
||||||
|
|
||||||
|
|
||||||
|
if artists != []:
|
||||||
|
maxbar = artists[0]["scrobbles"]
|
||||||
|
representative = artists[0]["artist"]
|
||||||
|
else:
|
||||||
|
representative = None
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
html = "<table class='list'>"
|
||||||
|
for e in artists:
|
||||||
|
i += 1
|
||||||
|
if max_ is not None and i>max_:
|
||||||
|
break
|
||||||
|
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"],kwargs_time,amount=e["scrobbles"],associated=True) + "</td>"
|
||||||
|
html += "<td class='bar'>" + scrobblesArtistLink(e["artist"],kwargs_time,percent=e["scrobbles"]*100/maxbar,associated=True) + "</td>"
|
||||||
|
html += "</tr>"
|
||||||
|
|
||||||
|
html += "</table>"
|
||||||
|
|
||||||
|
return (html, representative)
|
@ -14,7 +14,7 @@
|
|||||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text">
|
<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>
|
<span>KEY_ASSOCIATED</span>
|
||||||
<p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_SCROBBLES Scrobbles</a></p>
|
<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):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo
|
from utilities import getArtistInfo
|
||||||
from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, getRangeDesc, scrobblesLink
|
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"])
|
info = getArtistInfo(keys["artist"])
|
||||||
imgurl = info.get("image")
|
imgurl = info.get("image")
|
||||||
#desc = info.get("info")
|
#desc = info.get("info")
|
||||||
@ -27,47 +29,12 @@ def instructions(keys,dbport):
|
|||||||
includestr = "associated: "
|
includestr = "associated: "
|
||||||
includestr += artistLinks(included)
|
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)
|
return (replace,pushresources)
|
||||||
|
@ -4,29 +4,24 @@ import json
|
|||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
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)
|
filterkeys, timekeys, delimitkeys, _ = KeySplit(keys)
|
||||||
timekeys = pickKeys(keys,"since","to","in","step","trail")
|
|
||||||
limitkeys = pickKeys(keys,"artist","title","associated")
|
|
||||||
|
|
||||||
# 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)
|
# describe the scope (and creating a key for the relevant artist or track)
|
||||||
limitstring = ""
|
limitstring = ""
|
||||||
limitkey = {}
|
#limitkey = {}
|
||||||
if keys.get("title") is not None:
|
if filterkeys.get("track") is not None:
|
||||||
limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")}
|
#limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")}
|
||||||
limitstring += "of " + trackLink(limitkey["track"]) + " "
|
limitstring += "of " + trackLink(filterkeys["track"]) + " "
|
||||||
limitstring += "by " + artistLinks(keys.getall("artist"))
|
limitstring += "by " + artistLinks(filterkeys["track"]["artists"])
|
||||||
|
|
||||||
elif keys.get("artist") is not None:
|
elif filterkeys.get("artist") is not None:
|
||||||
limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
#limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None)
|
||||||
limitstring += "of " + artistLink(keys.get("artist"))
|
limitstring += "of " + artistLink(filterkeys.get("artist"))
|
||||||
if keys.get("associated") is not None:
|
if filterkeys.get("associated"):
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/artistinfo?artist=" + urllib.parse.quote(keys["artist"]))
|
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/artistinfo?artist=" + urllib.parse.quote(keys["artist"]))
|
||||||
db_data = json.loads(response.read())
|
db_data = json.loads(response.read())
|
||||||
moreartists = db_data["associated"]
|
moreartists = db_data["associated"]
|
||||||
@ -35,9 +30,9 @@ def instructions(keys,dbport):
|
|||||||
|
|
||||||
|
|
||||||
# get image
|
# get image
|
||||||
if limitkeys.get("title") is not None:
|
if filterkeys.get("track") is not None:
|
||||||
imgurl = getTrackInfo(limitkeys.getall("artist"),limitkeys.get("title")).get("image")
|
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
||||||
elif keys.get("artist") is not None:
|
elif filterkeys.get("artist") is not None:
|
||||||
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
||||||
#elif (len(scrobbles) != 0):
|
#elif (len(scrobbles) != 0):
|
||||||
# imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
# imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
||||||
@ -49,23 +44,9 @@ def instructions(keys,dbport):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# build list
|
html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys)
|
||||||
maxbar = max([t["scrobbles"] for t in terms])
|
|
||||||
|
|
||||||
html = "<table class='list'>"
|
replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
||||||
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}
|
|
||||||
|
|
||||||
return (replace,pushresources)
|
return (replace,pushresources)
|
||||||
|
|
||||||
|
@ -4,16 +4,11 @@ import json
|
|||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
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
|
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys,timekeys))
|
|
||||||
db_data = json.loads(response.read())
|
|
||||||
scrobbles = db_data["list"]
|
|
||||||
|
|
||||||
# describe the scope
|
# describe the scope
|
||||||
limitstring = ""
|
limitstring = ""
|
||||||
@ -30,33 +25,25 @@ def instructions(keys,dbport):
|
|||||||
if moreartists != []:
|
if moreartists != []:
|
||||||
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys)
|
||||||
|
|
||||||
# get image
|
# get image
|
||||||
if limitkeys.get("title") is not None:
|
if filterkeys.get("track") is not None:
|
||||||
imgurl = getTrackInfo(limitkeys.getall("artist"),limitkeys.get("title")).get("image")
|
imgurl = getTrackInfo(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]).get("image")
|
||||||
elif keys.get("artist") is not None:
|
elif filterkeys.get("artist") is not None:
|
||||||
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
imgurl = getArtistInfo(keys.get("artist")).get("image")
|
||||||
elif (len(scrobbles) != 0):
|
elif rep is not None:
|
||||||
imgurl = getTrackInfo(scrobbles[0]["artists"],scrobbles[0]["title"]).get("image")
|
imgurl = getTrackInfo(rep["artists"],rep["title"]).get("image")
|
||||||
#imgurl = getArtistInfo(scrobbles[0]["artists"][0]).get("image")
|
|
||||||
else:
|
else:
|
||||||
imgurl = ""
|
imgurl = ""
|
||||||
|
|
||||||
|
|
||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
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)
|
return (replace,pushresources)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1><a href="/topartists">Top Artists</a></h1>
|
<h1><a href="/topartists?max=50">Top Artists</a></h1>
|
||||||
<table class="tiles_top">
|
<table class="tiles_top">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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">
|
<table class="tiles_top">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -116,98 +116,9 @@
|
|||||||
<span class="stats">This year</span> KEY_SCROBBLES_YEAR
|
<span class="stats">This year</span> KEY_SCROBBLES_YEAR
|
||||||
<span class="stats">All Time</span> KEY_SCROBBLES_TOTAL
|
<span class="stats">All Time</span> KEY_SCROBBLES_TOTAL
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<table class='list'>
|
|
||||||
<tr>
|
KEY_SCROBBLES
|
||||||
<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>
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -220,70 +131,9 @@
|
|||||||
<a href="/pulse?step=year&trail=1">Years</a>
|
<a href="/pulse?step=year&trail=1">Years</a>
|
||||||
-->
|
-->
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<table class='list'>
|
|
||||||
|
KEY_PULSE
|
||||||
|
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ from threading import Thread
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
#import database
|
#import database
|
||||||
|
|
||||||
|
from htmlmodules import module_scrobblelist, module_pulse
|
||||||
|
|
||||||
|
|
||||||
def getpictures(ls,result,tracks=False):
|
def getpictures(ls,result,tracks=False):
|
||||||
from utilities import getArtistsInfo, getTracksInfo
|
from utilities import getArtistsInfo, getTracksInfo
|
||||||
@ -60,19 +62,21 @@ def instructions(keys,dbport):
|
|||||||
|
|
||||||
|
|
||||||
# get scrobbles
|
# get scrobbles
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?max=50")
|
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?max=50")
|
||||||
db_data = json.loads(response.read())
|
# db_data = json.loads(response.read())
|
||||||
scrobblelist = db_data["list"]
|
# scrobblelist = db_data["list"]
|
||||||
#scrobblelist = database.get_scrobbles(max=50)
|
# #scrobblelist = database.get_scrobbles(max=50)
|
||||||
scrobbletrackobjects = scrobblelist #ignore the extra time attribute, the format should still work
|
# 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]
|
# scrobbleartists = [", ".join([artistLink(a) for a in s["artists"]]) for s in scrobblelist]
|
||||||
scrobbletitles = [s["title"] for s in scrobblelist]
|
# scrobbletitles = [s["title"] for s in scrobblelist]
|
||||||
scrobbletimes = [getTimeDesc(s["time"],short=True) for s in scrobblelist]
|
# scrobbletimes = [getTimeDesc(s["time"],short=True) for s in scrobblelist]
|
||||||
scrobbleimages = []
|
# scrobbleimages = []
|
||||||
t3 = Thread(target=getpictures,args=(scrobbletrackobjects,scrobbleimages,),kwargs={"tracks":True})
|
# t3 = Thread(target=getpictures,args=(scrobbletrackobjects,scrobbleimages,),kwargs={"tracks":True})
|
||||||
t3.start()
|
# t3.start()
|
||||||
#scrobbleimages = [info.get("image") for info in getTracksInfo(scrobbletrackobjects)]
|
# #scrobbleimages = [info.get("image") for info in getTracksInfo(scrobbletrackobjects)]
|
||||||
scrobbletracklinks = [trackLink(t) for t in scrobbletrackobjects]
|
# scrobbletracklinks = [trackLink(t) for t in scrobbletrackobjects]
|
||||||
|
|
||||||
|
html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True)
|
||||||
|
|
||||||
|
|
||||||
# get stats
|
# 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
|
# this is literally the ugliest piece of code i have written in my entire feckin life
|
||||||
# good lord
|
# good lord
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=month&trail=1&since=" + dts)
|
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=month&trail=1&since=" + dts)
|
||||||
db_data = json.loads(response.read())
|
# db_data = json.loads(response.read())
|
||||||
terms = db_data["list"]
|
# terms = db_data["list"]
|
||||||
|
|
||||||
maxbar = max([t["scrobbles"] 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_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_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_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_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]
|
# 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()
|
t1.join()
|
||||||
t2.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,
|
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_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_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_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_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)
|
return (replace,pushresources)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<td class="text">
|
<td class="text">
|
||||||
<h1>Top Artists</h1><br/>
|
<h1>Top Artists</h1><br/>
|
||||||
<span>in KEY_RANGE</span>
|
<span>in KEY_RANGE</span>
|
||||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -4,47 +4,60 @@ import json
|
|||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo
|
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)
|
# clean(keys)
|
||||||
timekeys = pickKeys(keys,"since","to","in")
|
# timekeys = pickKeys(keys,"since","to","in")
|
||||||
limitkeys = pickKeys(keys)
|
# limitkeys = pickKeys(keys)
|
||||||
|
|
||||||
|
_, timekeys, _, amountkeys = KeySplit(keys)
|
||||||
|
|
||||||
# get chart data
|
# get chart data
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/artists?" + keysToUrl(timekeys,limitkeys))
|
||||||
db_data = json.loads(response.read())
|
# db_data = json.loads(response.read())
|
||||||
charts = db_data["list"][:50]
|
# charts = db_data["list"][:50]
|
||||||
topartist = charts[0]["artist"]
|
# 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
|
# get total amount of scrobbles
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||||
db_data = json.loads(response.read())
|
#db_data = json.loads(response.read())
|
||||||
scrobblelist = db_data["list"]
|
#scrobblelist = db_data["list"]
|
||||||
scrobbles = len(scrobblelist)
|
#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
|
# build list
|
||||||
maxbar = charts[0]["scrobbles"]
|
# maxbar = charts[0]["scrobbles"]
|
||||||
|
#
|
||||||
i = 1
|
# i = 1
|
||||||
html = "<table class='list'>"
|
# html = "<table class='list'>"
|
||||||
for e in charts:
|
# for e in charts:
|
||||||
html += "<tr>"
|
# html += "<tr>"
|
||||||
html += "<td class='rank'>#" + str(i) + "</td>"
|
# html += "<td class='rank'>#" + str(i) + "</td>"
|
||||||
html += "<td class='artist'>" + artistLink(e["artist"])
|
# html += "<td class='artist'>" + artistLink(e["artist"])
|
||||||
if (e["counting"] != []):
|
# if (e["counting"] != []):
|
||||||
html += " <span class='extra'>incl. " + ", ".join([artistLink(a) for a in e["counting"]]) + "</span>"
|
# html += " <span class='extra'>incl. " + ", ".join([artistLink(a) for a in e["counting"]]) + "</span>"
|
||||||
html += "</td>"
|
# html += "</td>"
|
||||||
html += "<td class='amount'>" + scrobblesArtistLink(e["artist"],timekeys,amount=e["scrobbles"],associated=True) + "</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 += "<td class='bar'>" + scrobblesArtistLink(e["artist"],timekeys,percent=e["scrobbles"]*100/maxbar,associated=True) + "</td>"
|
||||||
html += "</tr>"
|
# html += "</tr>"
|
||||||
i += 1
|
# i += 1
|
||||||
html += "</table>"
|
# 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)
|
return (replace,pushresources)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<td class="text">
|
<td class="text">
|
||||||
<h1>Top Tracks</h1><br/>
|
<h1>Top Tracks</h1><br/>
|
||||||
<span>KEY_LIMITS</span>
|
<span>KEY_LIMITS</span>
|
||||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -4,57 +4,70 @@ import json
|
|||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
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)
|
# clean(keys)
|
||||||
timekeys = pickKeys(keys,"since","to","in")
|
# timekeys = pickKeys(keys,"since","to","in")
|
||||||
limitkeys = pickKeys(keys,"artist")
|
# limitkeys = pickKeys(keys,"artist")
|
||||||
|
|
||||||
# get chart data
|
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/charts/tracks?" + keysToUrl(timekeys,limitkeys))
|
|
||||||
db_data = json.loads(response.read())
|
|
||||||
charts = db_data["list"][:50]
|
|
||||||
limitstring = ""
|
limitstring = ""
|
||||||
|
|
||||||
if keys.get("artist") is not None:
|
if filterkeys.get("artist") is not None:
|
||||||
topartist = keys.get("artist")
|
topartist = filterkeys.get("artist")
|
||||||
#limitstring += "by " + ", ".join([artistLink(a) for a in keys.getall("artist")])
|
# #limitstring += "by " + ", ".join([artistLink(a) for a in keys.getall("artist")])
|
||||||
limitstring = "by " + artistLink(keys.get("artist"))
|
limitstring = "by " + artistLink(filterkeys.get("artist"))
|
||||||
info = getArtistInfo(topartist)
|
# info = getArtistInfo(topartist)
|
||||||
imgurl = info.get("image")
|
# imgurl = info.get("image")
|
||||||
else:
|
# else:
|
||||||
#topartist = charts[0]["track"]["artists"][0] #for now
|
# #topartist = charts[0]["track"]["artists"][0] #for now
|
||||||
info = getTrackInfo(charts[0]["track"]["artists"],charts[0]["track"]["title"])
|
# info = getTrackInfo(charts[0]["track"]["artists"],charts[0]["track"]["title"])
|
||||||
imgurl = info.get("image")
|
# imgurl = info.get("image")
|
||||||
|
|
||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# get total amount of scrobbles
|
# get total amount of scrobbles
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(timekeys,limitkeys))
|
||||||
db_data = json.loads(response.read())
|
# db_data = json.loads(response.read())
|
||||||
scrobblelist = db_data["list"]
|
# scrobblelist = db_data["list"]
|
||||||
scrobbles = len(scrobblelist)
|
# 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
|
# build list
|
||||||
maxbar = charts[0]["scrobbles"]
|
# maxbar = charts[0]["scrobbles"]
|
||||||
|
#
|
||||||
i = 1
|
# i = 1
|
||||||
html = "<table class='list'>"
|
# html = "<table class='list'>"
|
||||||
for e in charts:
|
# for e in charts:
|
||||||
html += "<tr>"
|
# html += "<tr>"
|
||||||
html += "<td class='rank'>#" + str(i) + "</td>"
|
# html += "<td class='rank'>#" + str(i) + "</td>"
|
||||||
html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
# html += "<td class='artists'>" + artistLinks(e["track"]["artists"]) + "</td>"
|
||||||
html += "<td class='title'>" + trackLink(e["track"]) + "</td>"
|
# html += "<td class='title'>" + trackLink(e["track"]) + "</td>"
|
||||||
html += "<td class='amount'>" + scrobblesTrackLink(e["track"],timekeys,amount=e["scrobbles"]) + "</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 += "<td class='bar'>" + scrobblesTrackLink(e["track"],timekeys,percent=e["scrobbles"]*100/maxbar) + "</td>"
|
||||||
html += "</tr>"
|
# html += "</tr>"
|
||||||
i += 1
|
# i += 1
|
||||||
html += "</table>"
|
# 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)
|
return (replace,pushresources)
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="text">
|
<td class="text">
|
||||||
<span>KEY_ARTISTS</span><br/>
|
<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>
|
<p class="stats"><a href="/scrobbles?KEY_SCROBBLELINK">KEY_SCROBBLES Scrobbles</a></p>
|
||||||
|
|
||||||
|
@ -1,63 +1,67 @@
|
|||||||
import urllib
|
import urllib
|
||||||
import json
|
import json
|
||||||
|
import database
|
||||||
|
|
||||||
|
|
||||||
def instructions(keys,dbport):
|
def instructions(keys,dbport):
|
||||||
from utilities import getArtistInfo, getTrackInfo
|
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")
|
filterkeys, _, _, _ = KeySplit(keys)
|
||||||
trackobject = {"artists":limitkeys.getall("artist"),"title":limitkeys.get("title")}
|
|
||||||
info = getTrackInfo(keys.getall("artist"),keys.get("title"))
|
track = filterkeys.get("track")
|
||||||
imgurl = info.get("image")
|
imgurl = getTrackInfo(track["artists"],track["title"]).get("image")
|
||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/trackinfo?" + keysToUrl(limitkeys))
|
data = database.trackInfo(track["artists"],track["title"])
|
||||||
db_data = json.loads(response.read())
|
scrobblesnum = str(data["scrobbles"])
|
||||||
scrobblesnum = str(db_data["scrobbles"])
|
pos = "#" + str(data["position"])
|
||||||
pos = "#" + str(db_data["position"])
|
|
||||||
|
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys))
|
#response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys))
|
||||||
db_data = json.loads(response.read())
|
#db_data = json.loads(response.read())
|
||||||
scrobbles = db_data["list"]
|
#scrobbles = db_data["list"]
|
||||||
|
|
||||||
|
|
||||||
# build list
|
# build list
|
||||||
html = "<table class='list'>"
|
# html = "<table class='list'>"
|
||||||
for s in scrobbles:
|
# for s in scrobbles:
|
||||||
html += "<tr>"
|
# html += "<tr>"
|
||||||
html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
# html += "<td class='time'>" + getTimeDesc(s["time"]) + "</td>"
|
||||||
html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
# html += "<td class='artists'>" + artistLinks(s["artists"]) + "</td>"
|
||||||
html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
# html += "<td class='title'>" + trackLink({"artists":s["artists"],"title":s["title"]}) + "</td>"
|
||||||
html += "</tr>"
|
# html += "</tr>"
|
||||||
html += "</table>"
|
# html += "</table>"
|
||||||
|
|
||||||
|
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100)
|
||||||
|
|
||||||
# pulse
|
# pulse
|
||||||
response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=year&trail=1&" + keysToUrl(limitkeys))
|
# response = urllib.request.urlopen("http://[::1]:" + str(dbport) + "/pulse?step=year&trail=1&" + keysToUrl(limitkeys))
|
||||||
db_data = json.loads(response.read())
|
# db_data = json.loads(response.read())
|
||||||
terms = db_data["list"]
|
# terms = db_data["list"]
|
||||||
|
|
||||||
# build list
|
# build list
|
||||||
maxbar = max([t["scrobbles"] for t in terms])
|
# maxbar = max([t["scrobbles"] for t in terms])
|
||||||
|
|
||||||
html_pulse = "<table class='list'>"
|
# html_pulse = "<table class='list'>"
|
||||||
for t in terms:
|
# for t in terms:
|
||||||
fromstr = "/".join([str(e) for e in t["from"]])
|
# fromstr = "/".join([str(e) for e in t["from"]])
|
||||||
tostr = "/".join([str(e) for e in t["to"]])
|
# tostr = "/".join([str(e) for e in t["to"]])
|
||||||
html_pulse += "<tr>"
|
# html_pulse += "<tr>"
|
||||||
#html += "<td>" + fromstr + "</td>"
|
# #html += "<td>" + fromstr + "</td>"
|
||||||
#html += "<td>" + tostr + "</td>"
|
# #html += "<td>" + tostr + "</td>"
|
||||||
html_pulse += "<td>" + getRangeDesc(t["from"],t["to"]) + "</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='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 += "<td class='bar'>" + scrobblesLink({"since":fromstr,"to":tostr},percent=t["scrobbles"]*100/maxbar,track=trackobject) + "</td>"
|
||||||
html_pulse += "</tr>"
|
# html_pulse += "</tr>"
|
||||||
html_pulse += "</table>"
|
# 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)
|
return (replace,pushresources)
|
||||||
|
Loading…
Reference in New Issue
Block a user