diff --git a/README.md b/README.md index 281801d..cf744e5 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ I like to name my projects after regions in Grisons, Switzerland. Don't waste yo ## Current status -Deep in development. I just uploaded Maloja here in case I die tomorrow. It can accept scrobbles and return some basic stats in JSON format so far. +Deep in development. I just uploaded Maloja here in case I die tomorrow. It can accept scrobbles and return a few webpages (/artist, /scrobbles, /topartists). ## How to install diff --git a/cleanup.py b/cleanup.py index b2d4c76..7330529 100644 --- a/cleanup.py +++ b/cleanup.py @@ -76,7 +76,6 @@ class CleanerAgent: return [a.strip()] def parseTitle(self,t): - if t.strip() in self.rules_replacetitle: return self.rules_replacetitle[t.strip()] diff --git a/database.py b/database.py index 2c27650..8034b3b 100644 --- a/database.py +++ b/database.py @@ -116,7 +116,7 @@ def test_server(): @dbserver.route("/scrobbles") def get_scrobbles(): - keys = request.query + keys = FormsDict.decode(request.query) r = db_query(artist=keys.get("artist"),track=keys.get("track"),since=keys.get("since"),to=keys.get("to")) r.reverse() diff --git a/fixexisting.py b/fixexisting.py new file mode 100644 index 0000000..488f448 --- /dev/null +++ b/fixexisting.py @@ -0,0 +1,32 @@ +import os +import re +from cleanup import CleanerAgent + +wendigo = CleanerAgent() + +exp = r"([0-9]*)(\t+)([^\t]+?)(\t+)([^\t]+)(\t*)([^\t]*)\n" + +for fn in os.listdir("scrobbles/"): + if fn.endswith(".tsv"): + f = open("scrobbles/" + fn) + fnew = open("scrobbles/" + fn + "_new","w") + for l in f: + + a,t = re.sub(exp,r"\3",l), re.sub(exp,r"\5",l) + r1,r2,r3 = re.sub(exp,r"\1\2",l),re.sub(exp,r"\4",l),re.sub(exp,r"\6\7",l) + + a = a.replace("␟",";") + + (al,t) = wendigo.fullclean(a,t) + a = "␟".join(al) + fnew.write(r1 + a + r2 + t + r3 + "\n") + #print("Artists: " + a) + #print("Title: " + t) + #print("1: " + r1) + #print("2: " + r2) + #print("3: " + r3) + + f.close() + fnew.close() + + os.rename("scrobbles/" + fn + "_new","scrobbles/" + fn) diff --git a/website/artist.html b/website/artist.html index 02828d0..6c54f63 100644 --- a/website/artist.html +++ b/website/artist.html @@ -16,7 +16,7 @@

KEY_ARTISTNAME

KEY_POSITION
KEY_ASSOCIATED -

KEY_SCROBBLES Scrobbles

+

KEY_SCROBBLES Scrobbles

KEY_DESCRIPTION

diff --git a/website/artist.py b/website/artist.py index 88e5208..d7d7cde 100644 --- a/website/artist.py +++ b/website/artist.py @@ -31,11 +31,11 @@ def replacedict(keys,dbport): db_data = json.loads(response.read()) tracks = [] for e in db_data["list"]: - html = "" + html = "" for a in e["artists"]: html += "" + a + ", " html = html[:-2] - html += "" + e["title"] + "" + html += "" + e["title"] + "" tracks.append(html) trackshtml = "" @@ -46,4 +46,4 @@ def replacedict(keys,dbport): trackshtml += "
" - return {"KEY_ARTISTNAME":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":trackshtml,"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,"KEY_ASSOCIATED":includestr} diff --git a/website/maloja.css b/website/maloja.css index e473a25..6c9b939 100644 --- a/website/maloja.css +++ b/website/maloja.css @@ -43,3 +43,15 @@ table.top_info td.text h1 { table.top_info td.text .stats { color:grey; } + +table tr:nth-child(even) { + background-color:#37373B; +} + +table td.time { + width:200px; + color:lightgray; +} +table td.artists,td.artist,td.title,td.amount { + width:300px; +} diff --git a/website/scrobbles.py b/website/scrobbles.py index a10fc02..696c7f9 100644 --- a/website/scrobbles.py +++ b/website/scrobbles.py @@ -17,7 +17,7 @@ def replacedict(keys,dbport): limitstring = "" if keys.get("artist") is not None: - limitstring += "by " + keys.get("artist") + " " + limitstring += "by " + keys.get("artist") + " " response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys) @@ -26,15 +26,15 @@ def replacedict(keys,dbport): html = "" for s in scrobbles: - html += "" + html += "" html += "
" + html += "
" timestring = getTimeDesc(s["time"]) html += timestring - html += "" + html += "" artisthtml = "" for a in s["artists"]: artisthtml += "" + a + ", " html += artisthtml[:-2] - html += "" + s["title"] + "
" + s["title"] + "
" return {"KEY_SCROBBLELIST":html,"KEY_SCROBBLES":str(len(scrobbles)),"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring} diff --git a/website/topartists.py b/website/topartists.py index 0db14d3..cc1f734 100644 --- a/website/topartists.py +++ b/website/topartists.py @@ -27,9 +27,9 @@ def replacedict(keys,dbport): html = "" for e in charts: - html += "" + html += "" html += "
" + html += "
" html += "" + e["artist"] + "" - html += "" + str(e["scrobbles"]) + "
" + str(e["scrobbles"]) + "
" return {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_SCROBBLES":str(scrobbles),"KEY_ARTISTLIST":html}