diff --git a/database.py b/database.py index 2ef2b64..d10ae5c 100644 --- a/database.py +++ b/database.py @@ -343,6 +343,19 @@ def artistInfo(): artist = coa.getCredited(artist) c = [e for e in charts if e["artist"] == artist][0] return {"replace":artist,"scrobbles":scrobbles,"position":charts.index(c) + 1} + +@dbserver.route("/trackinfo") +def trackInfo(): + keys = FormsDict.decode(request.query) + artists = keys.getall("artist") + title = keys.get("title") + + charts = db_aggregate(by="TRACK") + scrobbles = len(db_query(artists=artists,title=title)) #we cant take the scrobble number from the charts because that includes all countas scrobbles + + + c = [e for e in charts if set(e["track"]["artists"]) == set(artists) and e["track"]["title"] == title][0] + return {"scrobbles":scrobbles,"position":charts.index(c) + 1} def isPast(date,limit): if not date[0] == limit[0]: diff --git a/htmlgenerators.py b/htmlgenerators.py index 4be75b7..e1d79a6 100644 --- a/htmlgenerators.py +++ b/htmlgenerators.py @@ -18,12 +18,12 @@ def trackLink(track): def scrobblesTrackLink(track,timekeys,amount=None,percent=None): artists,title = track["artists"],track["title"] import urllib - inner = str(amount) if amount is not None else "
" + inner = str(amount) if amount is not None else "" return "" + inner + "" def scrobblesArtistLink(artist,timekeys,amount=None,percent=None,associated=False): import urllib - inner = str(amount) if amount is not None else "" + inner = str(amount) if amount is not None else "" askey = "&associated" if associated else "" return "" + inner + "" diff --git a/website/track.html b/website/track.html new file mode 100644 index 0000000..aec76a3 --- /dev/null +++ b/website/track.html @@ -0,0 +1,30 @@ + + + + + ++ + | +
+ KEY_TRACKTITLEKEY_POSITION+ KEY_ARTISTS + + + + |
+
" + getTimeDesc(s["time"]) + " | " + html += "" + artistLinks(s["artists"]) + " | " + html += "" + trackLink({"artists":s["artists"],"title":s["title"]}) + " | " + html += "