mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Simplified some of the webpage building logic
This commit is contained in:
parent
7465eadf83
commit
eb9c9b2f69
@ -24,10 +24,10 @@ class CleanerAgent:
|
|||||||
title = self.parseTitle(self.removespecial(title))
|
title = self.parseTitle(self.removespecial(title))
|
||||||
(title,moreartists) = self.parseTitleForArtists(title)
|
(title,moreartists) = self.parseTitleForArtists(title)
|
||||||
artists += moreartists
|
artists += moreartists
|
||||||
|
artists = list(set(artists))
|
||||||
artists.sort()
|
artists.sort()
|
||||||
|
|
||||||
return (list(set(artists)),title)
|
return (artists,title)
|
||||||
|
|
||||||
def removespecial(self,s):
|
def removespecial(self,s):
|
||||||
s = s.replace("\t","").replace("␟","").replace("\n","")
|
s = s.replace("\t","").replace("␟","").replace("\n","")
|
||||||
|
@ -18,7 +18,6 @@ for fn in os.listdir("scrobbles/"):
|
|||||||
a = a.replace("␟",";")
|
a = a.replace("␟",";")
|
||||||
|
|
||||||
(al,t) = wendigo.fullclean(a,t)
|
(al,t) = wendigo.fullclean(a,t)
|
||||||
al.sort()
|
|
||||||
a = "␟".join(al)
|
a = "␟".join(al)
|
||||||
fnew.write(r1 + a + r2 + t + r3 + "\n")
|
fnew.write(r1 + a + r2 + t + r3 + "\n")
|
||||||
#print("Artists: " + a)
|
#print("Artists: " + a)
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
|
|
||||||
|
|
||||||
def replacedict(keys,dbport):
|
def replacedict(keys,dbport):
|
||||||
from utilities import getArtistInfo
|
from utilities import getArtistInfo, artistLink
|
||||||
|
|
||||||
|
|
||||||
info = getArtistInfo(keys["artist"])
|
info = getArtistInfo(keys["artist"])
|
||||||
@ -18,32 +18,28 @@ def replacedict(keys,dbport):
|
|||||||
credited = db_data.get("replace")
|
credited = db_data.get("replace")
|
||||||
includestr = " "
|
includestr = " "
|
||||||
if credited is not None:
|
if credited is not None:
|
||||||
includestr = "Competing under <a href=/artist?artist=" + urllib.parse.quote(credited) + ">" + credited + "</a> (" + pos + ")"
|
includestr = "Competing under " + artistLink(credited) + " (" + pos + ")"
|
||||||
pos = ""
|
pos = ""
|
||||||
included = db_data.get("associated")
|
included = db_data.get("associated")
|
||||||
if included is not None and included != []:
|
if included is not None and included != []:
|
||||||
includestr = "associated: "
|
includestr = "associated: "
|
||||||
for a in included:
|
#for a in included:
|
||||||
includestr += "<a href=/artist?artist=" + urllib.parse.quote(a) + ">" + a + "</a>, "
|
includestr += ", ".join([artistLink(a) for a in included]) #"<a href=/artist?artist=" + urllib.parse.quote(a) + ">" + a + "</a>, "
|
||||||
includestr = includestr[:-2]
|
#includestr = includestr[:-2]
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/tracks?artist=" + urllib.parse.quote(keys["artist"]))
|
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/tracks?artist=" + urllib.parse.quote(keys["artist"]))
|
||||||
db_data = json.loads(response.read())
|
db_data = json.loads(response.read())
|
||||||
tracks = []
|
|
||||||
|
html = "<table class='list'>"
|
||||||
for e in db_data["list"]:
|
for e in db_data["list"]:
|
||||||
html = "<td class='artists'>"
|
html += "<tr>"
|
||||||
for a in e["artists"]:
|
html += "<td class='artists'>"
|
||||||
html += "<a href=/artist?artist=" + urllib.parse.quote(a) + ">" + a + "</a>, "
|
links = [artistLink(a) for a in e["artists"]]
|
||||||
html = html[:-2]
|
html += ", ".join(links)
|
||||||
html += "</td><td class='title'>" + e["title"] + "</td>"
|
html += "</td><td class='title'>" + e["title"] + "</td>"
|
||||||
tracks.append(html)
|
html += "</tr>"
|
||||||
|
html += "</table>"
|
||||||
trackshtml = "<table class='list'>"
|
|
||||||
for t in tracks:
|
|
||||||
trackshtml += "<tr>"
|
|
||||||
trackshtml += t
|
|
||||||
trackshtml += "</tr>"
|
|
||||||
trackshtml += "</table>"
|
|
||||||
|
|
||||||
|
|
||||||
return {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":desc,"KEY_TRACKLIST":trackshtml,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr}
|
|
||||||
|
return {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":desc,"KEY_TRACKLIST":html,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr}
|
||||||
|
@ -12,7 +12,7 @@ def replacedict(keys,dbport):
|
|||||||
if db_data["inconsistent"]:
|
if db_data["inconsistent"]:
|
||||||
html += "<tr>"
|
html += "<tr>"
|
||||||
html += "<td>The current database wasn't built with all current rules in effect. Any problem below might be a false alarm and fixing it could create redundant rules.</td>"
|
html += "<td>The current database wasn't built with all current rules in effect. Any problem below might be a false alarm and fixing it could create redundant rules.</td>"
|
||||||
html += """<td class='button important' onclick="fullrebuild()">Rebuild the database</td>"""
|
html += """<td class='button important' onclick="fullrebuild()"><div>Rebuild the database</div></td>"""
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
i += 1
|
i += 1
|
||||||
for d in db_data["duplicates"]:
|
for d in db_data["duplicates"]:
|
||||||
@ -20,8 +20,8 @@ def replacedict(keys,dbport):
|
|||||||
html += "<td>'" + artistLink(d[0]) + "'"
|
html += "<td>'" + artistLink(d[0]) + "'"
|
||||||
html += " is a possible duplicate of "
|
html += " is a possible duplicate of "
|
||||||
html += "'" + artistLink(d[1]) + "'</td>"
|
html += "'" + artistLink(d[1]) + "'</td>"
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[0] + """','""" + d[1] + """')">""" + d[1] + """ is correct</td>"""
|
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[0] + """','""" + d[1] + """')"><div>""" + d[1] + """ is correct</div></td>"""
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[1] + """','""" + d[0] + """')">""" + d[0] + """ is correct</td>"""
|
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + d[1] + """','""" + d[0] + """')"><div>""" + d[0] + """ is correct</div></td>"""
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
i += 1
|
i += 1
|
||||||
for c in db_data["combined"]:
|
for c in db_data["combined"]:
|
||||||
@ -30,13 +30,13 @@ def replacedict(keys,dbport):
|
|||||||
for a in c[1]:
|
for a in c[1]:
|
||||||
html += "'" + artistLink(a) + "' "
|
html += "'" + artistLink(a) + "' "
|
||||||
html += "</td>"
|
html += "</td>"
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + c[0] + """','""" + "␟".join(c[1]) + """')">Fix it</td>"""
|
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + c[0] + """','""" + "␟".join(c[1]) + """')"><div>Fix it</div></td>"""
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
i += 1
|
i += 1
|
||||||
for n in db_data["newartists"]:
|
for n in db_data["newartists"]:
|
||||||
html += "<tr>"
|
html += "<tr>"
|
||||||
html += "<td>Is '" + n[0] + "' in '" + artistLink(n[1]) + "' an artist?</td>"
|
html += "<td>Is '" + n[0] + "' in '" + artistLink(n[1]) + "' an artist?</td>"
|
||||||
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + n[1] + """','""" + "␟".join(n[2] + [n[0]]) + """')">Yes</td>"""
|
html += """<td class='button' onclick="newrule(this,'replaceartist','""" + n[1] + """','""" + "␟".join(n[2] + [n[0]]) + """')"><div>Yes</div></td>"""
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
@ -51,12 +51,15 @@ table.top_info td.text .stats {
|
|||||||
text-align:right;
|
text-align:right;
|
||||||
color:grey;
|
color:grey;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
table.list {
|
table.list {
|
||||||
border-collapse:collapse;
|
border-collapse:collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.list tr {
|
table.list tr td {
|
||||||
border-bottom:2px solid;
|
border-bottom:2px solid;
|
||||||
border-color:rgba(0,0,0,0)
|
border-color:rgba(0,0,0,0)
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ table tr:nth-child(even) {
|
|||||||
background-color:#37373B;
|
background-color:#37373B;
|
||||||
}
|
}
|
||||||
|
|
||||||
table tr:nth-child(5n) {
|
table tr:nth-child(5n) td {
|
||||||
border-color:rgba(120,120,120,0.2);
|
border-color:rgba(120,120,120,0.2);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -83,7 +86,9 @@ table td.amount {
|
|||||||
text-align:right;
|
text-align:right;
|
||||||
}
|
}
|
||||||
table td.bar {
|
table td.bar {
|
||||||
width:300px;
|
width:500px;
|
||||||
|
background-color:#333337;
|
||||||
|
border-color:rgba(0,0,0,0)!important;
|
||||||
}
|
}
|
||||||
table td.bar div {
|
table td.bar div {
|
||||||
background-color:beige;
|
background-color:beige;
|
||||||
@ -97,14 +102,17 @@ table tr:hover td.bar div {
|
|||||||
|
|
||||||
table td.button {
|
table td.button {
|
||||||
width:200px;
|
width:200px;
|
||||||
background-color:yellow;
|
|
||||||
color:#333337;
|
|
||||||
padding:4px;
|
|
||||||
border-radius:4px;
|
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.button.important {
|
table td.button div {
|
||||||
|
background-color:yellow;
|
||||||
|
color:#333337;
|
||||||
|
padding:3px;
|
||||||
|
border-radius:4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.button.important div {
|
||||||
background-color:red;
|
background-color:red;
|
||||||
color:white;
|
color:white;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
|
|
||||||
|
|
||||||
def replacedict(keys,dbport):
|
def replacedict(keys,dbport):
|
||||||
from utilities import getArtistInfo, getTimeDesc
|
from utilities import getArtistInfo, getTimeDesc, artistLink
|
||||||
|
|
||||||
|
|
||||||
#hand down the since and from arguments
|
#hand down the since and from arguments
|
||||||
@ -17,8 +17,8 @@ def replacedict(keys,dbport):
|
|||||||
|
|
||||||
limitstring = ""
|
limitstring = ""
|
||||||
if keys.get("artist") is not None:
|
if keys.get("artist") is not None:
|
||||||
limitstring += "by <a href='/artist?artist=" + urllib.parse.quote(keys.get("artist")) + "'>" + keys.get("artist") + "</a> "
|
#limitstring += "by <a href='/artist?artist=" + urllib.parse.quote(keys.get("artist")) + "'>" + keys.get("artist") + "</a> "
|
||||||
|
limitstring += "by " + artistLink(keys.get("artist"))
|
||||||
|
|
||||||
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys)
|
response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys)
|
||||||
db_data = json.loads(response.read())
|
db_data = json.loads(response.read())
|
||||||
@ -30,10 +30,11 @@ def replacedict(keys,dbport):
|
|||||||
timestring = getTimeDesc(s["time"])
|
timestring = getTimeDesc(s["time"])
|
||||||
html += timestring
|
html += timestring
|
||||||
html += "</td><td class='artists'>"
|
html += "</td><td class='artists'>"
|
||||||
artisthtml = ""
|
html += ", ".join([artistLink(a) for a in s["artists"]])
|
||||||
for a in s["artists"]:
|
#artisthtml = ""
|
||||||
artisthtml += "<a href=/artist?artist=" + urllib.parse.quote(a) + ">" + a + "</a>, "
|
#for a in s["artists"]:
|
||||||
html += artisthtml[:-2]
|
# artisthtml += "<a href=/artist?artist=" + urllib.parse.quote(a) + ">" + a + "</a>, "
|
||||||
|
#html += artisthtml[:-2]
|
||||||
html += "</td><td class='title'>" + s["title"] + "</td></tr>"
|
html += "</td><td class='title'>" + s["title"] + "</td></tr>"
|
||||||
html += "</table>"
|
html += "</table>"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
|
|
||||||
|
|
||||||
def replacedict(keys,dbport):
|
def replacedict(keys,dbport):
|
||||||
from utilities import getArtistInfo
|
from utilities import getArtistInfo, artistLink
|
||||||
|
|
||||||
#hand down the since and from arguments
|
#hand down the since and from arguments
|
||||||
extrakeys = urllib.parse.urlencode(keys,quote_via=urllib.parse.quote,safe="/")
|
extrakeys = urllib.parse.urlencode(keys,quote_via=urllib.parse.quote,safe="/")
|
||||||
@ -30,9 +30,10 @@ def replacedict(keys,dbport):
|
|||||||
for e in charts:
|
for e in charts:
|
||||||
html += "<tr>"
|
html += "<tr>"
|
||||||
html += "<td class='rank'>#" + str(i) + "</td><td class='artist'>"
|
html += "<td class='rank'>#" + str(i) + "</td><td class='artist'>"
|
||||||
html += "<a href=/artist?artist=" + urllib.parse.quote(e["artist"]) + ">" + e["artist"] + "</a>"
|
#html += "<a href=/artist?artist=" + urllib.parse.quote(e["artist"]) + ">" + e["artist"] + "</a>"
|
||||||
|
html += artistLink(e["artist"])
|
||||||
html += "</td><td class='amount'><a href='/scrobbles?artist=" + urllib.parse.quote(e["artist"]) + "&" + extrakeys + "'>" + str(e["scrobbles"]) + "</a></td>"
|
html += "</td><td class='amount'><a href='/scrobbles?artist=" + urllib.parse.quote(e["artist"]) + "&" + extrakeys + "'>" + str(e["scrobbles"]) + "</a></td>"
|
||||||
html += "<td class='bar'><a href='/scrobbles?artist=" + urllib.parse.quote(e["artist"]) + "&" + extrakeys + "'><div style='width:" + str(int(e["scrobbles"]/maxbar * 100)) + "%;'></div></a></td>"
|
html += "<td class='bar'><a href='/scrobbles?artist=" + urllib.parse.quote(e["artist"]) + "&" + extrakeys + "'><div style='width:" + str(e["scrobbles"]/maxbar * 100) + "%;'></div></a></td>"
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
i += 1
|
i += 1
|
||||||
html += "</table>"
|
html += "</table>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user