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

37 lines
933 B
Python
Raw Normal View History

import urllib
def instructions(keys):
2018-12-29 02:08:00 +03:00
from utilities import getArtistInfo, getTrackInfo
from htmlgenerators import artistLink, KeySplit
2019-03-03 00:55:22 +03:00
from htmlmodules import module_trackcharts
from malojatime import range_desc
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
limitstring = ""
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
if filterkeys.get("artist") is not None:
imgurl = getArtistInfo(filterkeys.get("artist")).get("image")
limitstring = "by " + artistLink(filterkeys.get("artist"))
elif rep is not None:
imgurl = getTrackInfo(rep["artists"],rep["title"]).get("image")
else:
imgurl = ""
2019-03-03 00:55:22 +03:00
limitstring += " " + range_desc(**timekeys)
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring}
return (replace,pushresources)