From 08de19459c5208e898caab33e57b12c205a17fa9 Mon Sep 17 00:00:00 2001 From: Krateng Date: Mon, 17 Dec 2018 16:33:26 +0100 Subject: [PATCH] Added UI for artist charts --- website/.gitignore | 1 - website/artist.html | 6 +++--- website/artist.py | 1 + website/maloja.css | 9 ++++++++- website/topartists.html | 21 ++++++++++++++++++--- website/topartists.py | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 website/topartists.py diff --git a/website/.gitignore b/website/.gitignore index da54ded..bee8a64 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -1,2 +1 @@ __pycache__ -apikey diff --git a/website/artist.html b/website/artist.html index 910efad..c952b11 100644 --- a/website/artist.html +++ b/website/artist.html @@ -3,7 +3,7 @@ - Maloja + Maloja - KEY_ARTISTNAME @@ -11,10 +11,10 @@
- +
-

KEY_ARTISTNAME

KEY_POSITION
+

KEY_ARTISTNAME

KEY_POSITION
KEY_ASSOCIATED

KEY_SCROBBLES Scrobbles

diff --git a/website/artist.py b/website/artist.py index fc39c67..88e5208 100644 --- a/website/artist.py +++ b/website/artist.py @@ -14,6 +14,7 @@ def replacedict(keys,dbport): db_data = json.loads(response.read()) scrobbles = str(db_data["scrobbles"]) pos = "#" + str(db_data["position"]) + credited = db_data.get("replace") includestr = " " if credited is not None: diff --git a/website/maloja.css b/website/maloja.css index d4ceff2..4123773 100644 --- a/website/maloja.css +++ b/website/maloja.css @@ -8,7 +8,7 @@ body { } a { - color:lightgray; + color:inherit; text-decoration:none; } @@ -22,6 +22,13 @@ table.top_info td.image { padding-top:0px; } +table.top_info td.image div { + background-size:cover; + background-position:center; + height:174px; + width:174px +} + table.top_info td.text { vertical-align: top; padding-left: 30px; diff --git a/website/topartists.html b/website/topartists.html index 2b1f5ee..6290139 100644 --- a/website/topartists.html +++ b/website/topartists.html @@ -3,12 +3,27 @@ - Maloja + Maloja - Top Artists in KEY_RANGE -

Top Artists

-

in January 2018

+ + + + + +
+
+
+

Top Artists


+ in KEY_RANGE +

KEY_SCROBBLES Scrobbles

+ +
+ + + KEY_ARTISTLIST + diff --git a/website/topartists.py b/website/topartists.py new file mode 100644 index 0000000..0db14d3 --- /dev/null +++ b/website/topartists.py @@ -0,0 +1,36 @@ +import urllib +import json + + +def replacedict(keys,dbport): + from utilities import getArtistInfo + + #hand down the since and from arguments + extrakeys = urllib.parse.urlencode(keys) + + response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/charts/artists?" + extrakeys) + db_data = json.loads(response.read()) + charts = db_data["list"][:50] + topartist = charts[0]["artist"] + + info = getArtistInfo(topartist) + imgurl = info.get("image") + + + response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys) + db_data = json.loads(response.read()) + scrobblelist = db_data["list"] + scrobbles = len(scrobblelist) + + + + + html = "" + for e in charts: + html += "" + html += "
" + html += "" + e["artist"] + "" + html += "" + str(e["scrobbles"]) + "
" + + return {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_ARTISTLIST":html} +