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

Fancy af start page

This commit is contained in:
Krateng 2019-02-03 16:52:37 +01:00
parent ae4b111bee
commit ed990f59fc
8 changed files with 235 additions and 8 deletions

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

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

View File

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

View File

@ -108,5 +108,168 @@
</tr>
</table>
<div class="sidelist">
<h1><a href="/scrobbles?max=100">Last Scrobbles</a></h1>
<table class='list'>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
<tr>
<td class='time'>KEY_SCROBBLE_TIME</td>
<td class='icon'><div style="background-image:url('KEY_SCROBBLE_IMAGE')"></div></td>
<td class='artists'>KEY_SCROBBLE_ARTISTS</td>
<td class='title'>KEY_SCROBBLE_TITLE</td>
</tr>
</table>
</div>
</body>
</html>

View File

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