2018-12-22 16:06:21 +03:00
|
|
|
import urllib
|
|
|
|
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-21 11:43:35 +03:00
|
|
|
def instructions(keys):
|
2019-03-12 13:39:36 +03:00
|
|
|
from utilities import getArtistImage, getTrackImage
|
2019-04-08 14:04:31 +03:00
|
|
|
from htmlgenerators import artistLink
|
|
|
|
from urihandler import compose_querystring, uri_to_internal
|
2019-09-04 08:58:28 +03:00
|
|
|
from htmlmodules import module_trackcharts, module_filterselection, module_trackcharts_tiles
|
2019-03-03 00:55:22 +03:00
|
|
|
from malojatime import range_desc
|
2019-09-04 08:58:28 +03:00
|
|
|
from doreah.settings import get_settings
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-04-08 14:04:31 +03:00
|
|
|
filterkeys, timekeys, _, amountkeys = uri_to_internal(keys)
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-04-23 19:15:44 +03:00
|
|
|
if len(filterkeys) == 0:
|
|
|
|
toptrackslink = "<a href='/top_tracks'><span>View #1 Tracks</span></a>"
|
|
|
|
else:
|
|
|
|
toptrackslink = ""
|
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
|
2018-12-22 16:06:21 +03:00
|
|
|
limitstring = ""
|
2019-02-20 20:22:45 +03:00
|
|
|
|
2019-04-01 19:43:08 +03:00
|
|
|
html_filterselector = module_filterselection(keys)
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-09-05 15:53:09 +03:00
|
|
|
|
2019-09-04 08:58:28 +03:00
|
|
|
|
2019-09-21 21:51:49 +03:00
|
|
|
html_tiles = ""
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
if filterkeys.get("artist") is not None:
|
2019-03-12 13:39:36 +03:00
|
|
|
imgurl = getArtistImage(filterkeys.get("artist"))
|
2019-02-20 20:22:45 +03:00
|
|
|
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"])
|
2019-02-20 20:22:45 +03:00
|
|
|
else:
|
|
|
|
imgurl = ""
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-09-21 21:51:49 +03:00
|
|
|
html_tiles = ""
|
|
|
|
if get_settings("CHARTS_DISPLAY_TILES"):
|
|
|
|
html_tiles = module_trackcharts_tiles(timerange=timekeys["timerange"])
|
|
|
|
imgurl = "favicon.png"
|
|
|
|
|
|
|
|
imgdiv = '<div style="background-image:url('+imgurl+')"></div>'
|
|
|
|
|
2019-09-05 15:53:09 +03:00
|
|
|
|
2019-09-04 08:58:28 +03:00
|
|
|
|
2019-04-10 16:45:50 +03:00
|
|
|
limitstring += " " + timekeys["timerange"].desc(prefix=True)
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-21 11:43:35 +03:00
|
|
|
|
2018-12-22 16:06:21 +03:00
|
|
|
|
2019-04-23 19:15:44 +03:00
|
|
|
replace = {
|
2019-09-04 08:58:28 +03:00
|
|
|
"KEY_TOPARTIST_IMAGEDIV":imgdiv,
|
2019-09-21 21:51:49 +03:00
|
|
|
"KEY_TRACKCHART":html_tiles,
|
2019-04-23 19:15:44 +03:00
|
|
|
"KEY_TRACKLIST":html_charts,
|
|
|
|
"KEY_LIMITS":limitstring,
|
|
|
|
"KEY_FILTERSELECTOR":html_filterselector,
|
|
|
|
"TOP_TRACKS_LINK":toptrackslink,
|
|
|
|
}
|
2018-12-22 16:06:21 +03:00
|
|
|
|
2019-03-29 21:44:42 +03:00
|
|
|
return (replace,pushresources)
|