2018-12-22 16:06:21 +03:00
|
|
|
import urllib
|
|
|
|
|
|
|
|
|
2019-02-21 11:43:35 +03:00
|
|
|
def instructions(keys):
|
2018-12-29 02:08:00 +03:00
|
|
|
from utilities import getArtistInfo, getTrackInfo
|
2019-02-20 20:22:45 +03:00
|
|
|
from htmlgenerators import artistLink, KeySplit
|
2019-03-03 00:55:22 +03:00
|
|
|
from htmlmodules import module_trackcharts
|
|
|
|
from malojatime import range_desc
|
2018-12-22 16:06:21 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
filterkeys, timekeys, _, amountkeys = KeySplit(keys)
|
|
|
|
|
|
|
|
|
2018-12-22 16:06:21 +03:00
|
|
|
limitstring = ""
|
2019-02-20 20:22:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2019-02-20 20:22:45 +03:00
|
|
|
|
|
|
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
|
|
|
|
2019-02-21 11:43:35 +03:00
|
|
|
|
2018-12-22 16:06:21 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring}
|
2019-02-17 16:25:40 +03:00
|
|
|
|
|
|
|
return (replace,pushresources)
|
2018-12-22 16:06:21 +03:00
|
|
|
|