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:
parent
78b1937044
commit
08de19459c
1
website/.gitignore
vendored
1
website/.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
apikey
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Maloja</title>
|
<title>Maloja - KEY_ARTISTNAME</title>
|
||||||
<link rel="stylesheet" href="maloja.css" />
|
<link rel="stylesheet" href="maloja.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -11,10 +11,10 @@
|
|||||||
<table class="top_info">
|
<table class="top_info">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="image">
|
<td class="image">
|
||||||
<img src="KEY_IMAGEURL" />
|
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text">
|
<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>
|
<span>KEY_ASSOCIATED</span>
|
||||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ def replacedict(keys,dbport):
|
|||||||
db_data = json.loads(response.read())
|
db_data = json.loads(response.read())
|
||||||
scrobbles = str(db_data["scrobbles"])
|
scrobbles = str(db_data["scrobbles"])
|
||||||
pos = "#" + str(db_data["position"])
|
pos = "#" + str(db_data["position"])
|
||||||
|
|
||||||
credited = db_data.get("replace")
|
credited = db_data.get("replace")
|
||||||
includestr = " "
|
includestr = " "
|
||||||
if credited is not None:
|
if credited is not None:
|
||||||
|
@ -8,7 +8,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color:lightgray;
|
color:inherit;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,6 +22,13 @@ table.top_info td.image {
|
|||||||
padding-top:0px;
|
padding-top:0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.top_info td.image div {
|
||||||
|
background-size:cover;
|
||||||
|
background-position:center;
|
||||||
|
height:174px;
|
||||||
|
width:174px
|
||||||
|
}
|
||||||
|
|
||||||
table.top_info td.text {
|
table.top_info td.text {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
|
@ -3,12 +3,27 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Maloja</title>
|
<title>Maloja - Top Artists in KEY_RANGE</title>
|
||||||
<link rel="stylesheet" href="maloja.css" />
|
<link rel="stylesheet" href="maloja.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Top Artists</h1>
|
<table class="top_info">
|
||||||
<h2>in January 2018</h2>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
36
website/topartists.py
Normal file
36
website/topartists.py
Normal 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}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user