diff --git a/htmlgenerators.py b/htmlgenerators.py index e1d79a6..bbe32a3 100644 --- a/htmlgenerators.py +++ b/htmlgenerators.py @@ -60,10 +60,31 @@ def removeIdentical(*dicts): return new -def getTimeDesc(timestamp): +def getTimeDesc(timestamp,short=False): import datetime tim = datetime.datetime.utcfromtimestamp(timestamp) - return tim.strftime("%d. %b %Y %I:%M %p") + if short: + now = datetime.datetime.utcnow() + datestring = "" + if tim.year < now.year: + return str(tim.year) + if tim.month < now.month: + return tim.strftime("%B") + if tim.day+1 < now.day: + return tim.strftime("%d. %B") + if tim.day+1 == now.day: + return "yesterday" + if tim.hour+1 < now.hour: + return str(now.hour - tim.hour) + " hours ago" + if tim.minute+1 < now.minute: + return str(now.minute - tim.minute) + " minutes ago" + if tim.second+10 < now.second: + return str(now.second - tim.second) + " seconds ago" + + return "just now" + return tim.strftime("%d. %b %Y") + else: + return tim.strftime("%d. %b %Y %I:%M %p") # limit a multidict to only the specified keys diff --git a/utilities.py b/utilities.py index cea4f92..ba652f0 100644 --- a/utilities.py +++ b/utilities.py @@ -301,4 +301,5 @@ def getArtistsInfo(artistlist): # async calls only cached results, now we need to get them return [getArtistInfo(a) for a in artistlist] + diff --git a/website/favicon.ico b/website/favicon.ico index 03e8803..fe291ce 100644 Binary files a/website/favicon.ico and b/website/favicon.ico differ diff --git a/website/favicon.png b/website/favicon.png index 6ef8fd5..220dc24 100644 Binary files a/website/favicon.png and b/website/favicon.png differ diff --git a/website/maloja.css b/website/maloja.css index 850c863..0bef41d 100644 --- a/website/maloja.css +++ b/website/maloja.css @@ -127,10 +127,20 @@ table td.time { } table td.icon { + /*width:20px!important; + height:20px; + background-size:cover; + background-position:center; + padding-right:6px;*/ + padding:0px; +} + +table td.icon div { width:20px; height:20px; background-size:cover; background-position:center; + margin-right:4px; } table td.artists,td.artist,td.title { @@ -279,3 +289,27 @@ table.tiles_3x3 td { width:33.333%; font-size:70% } + + + + + +/* +** +** +** SIDE LIST ON START PAGE +** +** +*/ + + + +div.sidelist { + position:absolute; + right:0px; + top:0px; + width:40%; + height:100%; + background-color:#444447; + padding-left:30px; +} diff --git a/website/scrobbles.py b/website/scrobbles.py index 2076d31..995c620 100644 --- a/website/scrobbles.py +++ b/website/scrobbles.py @@ -7,7 +7,7 @@ def replacedict(keys,dbport): from htmlgenerators import getTimeDesc, artistLink, artistLinks, trackLink, keysToUrl, pickKeys, clean clean(keys) - timekeys = pickKeys(keys,"since","to","in") + timekeys = pickKeys(keys,"since","to","in","max") limitkeys = pickKeys(keys,"artist","title","associated") # Get scrobble data diff --git a/website/start.html b/website/start.html index b79d76b..54bf645 100644 --- a/website/start.html +++ b/website/start.html @@ -108,5 +108,168 @@ + + + + + + +
+

Last Scrobbles

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
KEY_SCROBBLE_TIME
KEY_SCROBBLE_ARTISTSKEY_SCROBBLE_TITLE
+
+ diff --git a/website/start.py b/website/start.py index b97d856..8d580bf 100644 --- a/website/start.py +++ b/website/start.py @@ -4,7 +4,7 @@ import json def replacedict(keys,dbport): from utilities import getArtistInfo, getArtistsInfo, getTracksInfo - from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, keysToUrl, pickKeys, clean + from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesArtistLink, keysToUrl, pickKeys, clean, getTimeDesc max_show = 15 posrange = ["#" + str(i) for i in range(1,max_show)] @@ -39,9 +39,16 @@ def replacedict(keys,dbport): # get scrobbles - #response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles") - #db_data = json.loads(response.read()) - #scrobblelist = db_data["list"] + response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?max=50") + db_data = json.loads(response.read()) + scrobblelist = db_data["list"] + scrobbletrackobjects = scrobblelist #ignore the extra time attribute, the format should still work + scrobbleartists = [", ".join([artistLink(a) for a in s["artists"]]) for s in scrobblelist] + scrobbletitles = [s["title"] for s in scrobblelist] + scrobbletimes = [getTimeDesc(s["time"],short=True) for s in scrobblelist] + scrobbleimages = [info.get("image") for info in getTracksInfo(scrobbletrackobjects)] + scrobbletracklinks = [trackLink(t) for t in scrobbletrackobjects] + # get stats response = urllib.request.urlopen("http://localhost:" +str(dbport) + "/numscrobbles?since=today") @@ -64,5 +71,6 @@ def replacedict(keys,dbport): return {"KEY_ARTISTIMAGE":artistimages,"KEY_ARTISTNAME":artisttitles,"KEY_ARTISTLINK":artistlinks,"KEY_POSITION_ARTIST":posrange, "KEY_TRACKIMAGE":trackimages,"KEY_TRACKNAME":tracktitles,"KEY_TRACKLINK":tracklinks,"KEY_POSITION_TRACK":posrange, - "KEY_SCROBBLES_TODAY":scrobbles_today,"KEY_SCROBBLES_MONTH":scrobbles_month,"KEY_SCROBBLES_YEAR":scrobbles_year,"KEY_SCROBBLES_TOTAL":scrobbles_total} + "KEY_SCROBBLES_TODAY":scrobbles_today,"KEY_SCROBBLES_MONTH":scrobbles_month,"KEY_SCROBBLES_YEAR":scrobbles_year,"KEY_SCROBBLES_TOTAL":scrobbles_total, + "KEY_SCROBBLE_TIME":scrobbletimes,"KEY_SCROBBLE_ARTISTS":scrobbleartists,"KEY_SCROBBLE_TITLE":scrobbletracklinks,"KEY_SCROBBLE_IMAGE":scrobbleimages}