1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added UI for artist charts

This commit is contained in:
Krateng 2018-12-17 16:33:26 +01:00
parent 78b1937044
commit 08de19459c
6 changed files with 66 additions and 8 deletions

1
website/.gitignore vendored
View File

@ -1,2 +1 @@
__pycache__
apikey

View File

@ -3,7 +3,7 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Maloja</title>
<title>Maloja - KEY_ARTISTNAME</title>
<link rel="stylesheet" href="maloja.css" />
</head>
@ -11,10 +11,10 @@
<table class="top_info">
<tr>
<td class="image">
<img src="KEY_IMAGEURL" />
<div style="background-image:url('KEY_IMAGEURL')"></div>
</td>
<td class="text">
<h1>KEY_ARTISTNAME</h1> <span class="stats">KEY_POSITION</span><br/>
<h1>KEY_ARTISTNAME</h1> <span class="stats">KEY_POSITION</span><br/>
<span>KEY_ASSOCIATED</span>
<p class="stats">KEY_SCROBBLES Scrobbles</p>

View File

@ -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:

View File

@ -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;

View File

@ -3,12 +3,27 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Maloja</title>
<title>Maloja - Top Artists in KEY_RANGE</title>
<link rel="stylesheet" href="maloja.css" />
</head>
<body>
<h1>Top Artists</h1>
<h2>in January 2018</h2>
<table class="top_info">
<tr>
<td class="image">
<div style="background-image:url('KEY_TOPARTIST_IMAGEURL')"></div>
</td>
<td class="text">
<h1>Top Artists</h1> <span class="stats"></span><br/>
<span>in KEY_RANGE</span>
<p class="stats">KEY_SCROBBLES Scrobbles</p>
</td>
</tr>
</table>
KEY_ARTISTLIST
</body>
</html>

36
website/topartists.py Normal file
View File

@ -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 = "<table>"
for e in charts:
html += "<tr><td>"
html += "<a href=/artist?artist=" + urllib.parse.quote(e["artist"]) + ">" + e["artist"] + "</a>"
html += "</td><td>" + str(e["scrobbles"]) + "</td></tr>"
html += "</table>"
return {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_ARTISTLIST":html}