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

37 lines
1012 B
Python
Raw Normal View History

import urllib
2019-03-29 21:44:42 +03:00
def instructions(keys):
2019-03-12 13:39:36 +03:00
from utilities import getArtistImage, getTrackImage
from htmlgenerators import artistLink, KeySplit
from htmlmodules import module_trackcharts, module_filterselection
2019-03-03 00:55:22 +03:00
from malojatime import range_desc
2019-03-29 21:44:42 +03:00
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
2019-03-29 21:44:42 +03:00
limitstring = ""
2019-04-01 19:43:08 +03:00
html_filterselector = module_filterselection(keys)
2019-03-29 21:44:42 +03:00
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
2019-03-29 21:44:42 +03:00
if filterkeys.get("artist") is not None:
2019-03-12 13:39:36 +03:00
imgurl = getArtistImage(filterkeys.get("artist"))
limitstring = "by " + artistLink(filterkeys.get("artist"))
elif rep is not None:
2019-03-29 21:44:42 +03:00
imgurl = getTrackImage(rep["artists"],rep["title"])
else:
imgurl = ""
2019-03-29 21:44:42 +03:00
2019-03-03 00:55:22 +03:00
limitstring += " " + range_desc(**timekeys)
2019-03-29 21:44:42 +03:00
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
2019-03-29 21:44:42 +03:00
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring,"KEY_FILTERSELECTOR":html_filterselector}
2019-03-29 21:44:42 +03:00
return (replace,pushresources)