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

Modularized tile charts on start page and added options for different ranges

This commit is contained in:
Krateng
2019-03-03 21:22:42 +01:00
parent 1809da38e6
commit b8fe71515c
6 changed files with 183 additions and 106 deletions

View File

@ -2,7 +2,7 @@ import urllib
from datetime import datetime, timedelta
import database
from htmlmodules import module_scrobblelist, module_pulse
from htmlmodules import module_scrobblelist, module_pulse, module_artistcharts_tiles, module_trackcharts_tiles
def instructions(keys):
@ -15,19 +15,28 @@ def instructions(keys):
# get chart data
# artists
charts = database.get_charts_artists()[:max_show]
artisttitles = [c["artist"] for c in charts]
artistimages = ["/image?artist=" + urllib.parse.quote(a) for a in artisttitles]
artistlinks = [artistLink(a) for a in artisttitles]
# charts = database.get_charts_artists()[:max_show]
# artisttitles = [c["artist"] for c in charts]
# artistimages = ["/image?artist=" + urllib.parse.quote(a) for a in artisttitles]
# artistlinks = [artistLink(a) for a in artisttitles]
topartists_total = module_artistcharts_tiles()
topartists_year = module_artistcharts_tiles(since="year")
topartists_month = module_artistcharts_tiles(since="month")
#topartists_week = module_artistcharts_tiles(since="week")
# tracks
charts = database.get_charts_tracks()[:max_show]
trackobjects = [t["track"] for t in charts]
tracktitles = [t["title"] for t in trackobjects]
trackimages = ["/image?title=" + urllib.parse.quote(t["title"]) + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in t["artists"]]) for t in trackobjects]
tracklinks = [trackLink(t) for t in trackobjects]
# charts = database.get_charts_tracks()[:max_show]
# trackobjects = [t["track"] for t in charts]
# tracktitles = [t["title"] for t in trackobjects]
# trackimages = ["/image?title=" + urllib.parse.quote(t["title"]) + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in t["artists"]]) for t in trackobjects]
# tracklinks = [trackLink(t) for t in trackobjects]
toptracks_total = module_trackcharts_tiles()
toptracks_year = module_trackcharts_tiles(since="year")
toptracks_month = module_trackcharts_tiles(since="month")
#toptracks_week = module_trackcharts_tiles(since="week")
# get scrobbles
html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True)
@ -69,10 +78,14 @@ def instructions(keys):
html_pulse_months = module_pulse(max_=12,since=first_month,step="month",trail=1)
html_pulse_years = module_pulse(max_=10,since=first_year,step="year",trail=1)
pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that
#pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that
pushresources = []
replace = {"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,
replace = {
# "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_TOPARTISTS_TOTAL":topartists_total,"KEY_TOPARTISTS_YEAR":topartists_year,"KEY_TOPARTISTS_MONTH":topartists_month,#"KEY_TOPARTISTS_WEEK":topartists_week,
"KEY_TOPTRACKS_TOTAL":toptracks_total,"KEY_TOPTRACKS_YEAR":toptracks_year,"KEY_TOPTRACKS_MONTH":toptracks_month,#"KEY_TOPTRACKS_WEEK":toptracks_week,
"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,
"KEY_SCROBBLES":html_scrobbles,