2018-12-19 18:11:10 +03:00
|
|
|
import urllib
|
2019-02-20 23:10:58 +03:00
|
|
|
import database
|
2018-12-19 18:11:10 +03:00
|
|
|
|
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, artistLinks, trackLink
|
|
|
|
from urihandler import compose_querystring, uri_to_internal
|
2019-04-02 13:59:42 +03:00
|
|
|
from htmlmodules import module_scrobblelist, module_filterselection
|
2019-03-03 00:55:22 +03:00
|
|
|
from malojatime import range_desc
|
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
|
|
|
|
2018-12-27 05:09:29 +03:00
|
|
|
# describe the scope
|
|
|
|
limitstring = ""
|
2019-02-20 23:10:58 +03:00
|
|
|
if filterkeys.get("track") is not None:
|
|
|
|
limitstring += "of " + trackLink(filterkeys["track"]) + " "
|
|
|
|
limitstring += "by " + artistLinks(filterkeys["track"]["artists"])
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
elif filterkeys.get("artist") is not None:
|
|
|
|
limitstring += "by " + artistLink(filterkeys.get("artist"))
|
|
|
|
if filterkeys.get("associated"):
|
|
|
|
data = database.artistInfo(filterkeys["artist"])
|
|
|
|
moreartists = data.get("associated")
|
2018-12-23 01:19:52 +03:00
|
|
|
if moreartists != []:
|
2018-12-27 05:09:29 +03:00
|
|
|
limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-03-03 00:55:22 +03:00
|
|
|
limitstring += " " + range_desc(**timekeys)
|
2019-02-20 20:22:45 +03:00
|
|
|
|
2019-04-02 13:59:42 +03:00
|
|
|
html_filterselector = module_filterselection(keys)
|
|
|
|
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys)
|
2019-03-29 21:44:42 +03:00
|
|
|
|
|
|
|
# get image
|
2019-02-20 20:22:45 +03:00
|
|
|
if filterkeys.get("track") is not None:
|
2019-03-12 13:39:36 +03:00
|
|
|
imgurl = getTrackImage(filterkeys.get("track")["artists"],filterkeys.get("track")["title"],fast=True)
|
2019-02-20 20:22:45 +03:00
|
|
|
elif filterkeys.get("artist") is not None:
|
2019-03-12 13:39:36 +03:00
|
|
|
imgurl = getArtistImage(keys.get("artist"),fast=True)
|
2019-02-20 20:22:45 +03:00
|
|
|
elif rep is not None:
|
2019-03-12 13:39:36 +03:00
|
|
|
imgurl = getTrackImage(rep["artists"],rep["title"],fast=True)
|
2018-12-23 01:19:52 +03:00
|
|
|
else:
|
2018-12-27 05:09:29 +03:00
|
|
|
imgurl = ""
|
2019-03-29 21:44:42 +03:00
|
|
|
|
|
|
|
|
2019-02-17 16:25:40 +03:00
|
|
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
2018-12-23 01:19:52 +03:00
|
|
|
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-04-02 13:59:42 +03:00
|
|
|
replace = {"KEY_SCROBBLELIST":html,
|
|
|
|
"KEY_SCROBBLES":str(amount),
|
|
|
|
"KEY_IMAGEURL":imgurl,
|
|
|
|
"KEY_LIMITS":limitstring,
|
|
|
|
"KEY_FILTERSELECTOR":html_filterselector}
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-17 16:25:40 +03:00
|
|
|
return (replace,pushresources)
|