2018-12-16 19:52:13 +03:00
|
|
|
import urllib
|
2019-02-20 23:10:58 +03:00
|
|
|
import database
|
2018-12-16 19:52:13 +03:00
|
|
|
|
|
|
|
|
2019-02-21 11:43:35 +03:00
|
|
|
def instructions(keys):
|
2018-12-26 21:20:26 +03:00
|
|
|
from utilities import getArtistInfo
|
2019-03-03 00:55:22 +03:00
|
|
|
from htmlgenerators import artistLink, artistLinks, KeySplit
|
2019-02-20 20:22:45 +03:00
|
|
|
from htmlmodules import module_pulse, module_trackcharts
|
2018-12-16 19:52:13 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
filterkeys, _, _, _ = KeySplit(keys,forceArtist=True)
|
|
|
|
info = getArtistInfo(filterkeys["artist"])
|
2018-12-17 17:10:10 +03:00
|
|
|
imgurl = info.get("image")
|
2019-02-17 16:25:40 +03:00
|
|
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
2018-12-16 19:52:13 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
data = database.artistInfo(filterkeys["artist"])
|
|
|
|
scrobbles = str(data["scrobbles"])
|
|
|
|
pos = "#" + str(data["position"])
|
2018-12-17 18:33:26 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
credited = data.get("replace")
|
2018-12-17 01:56:30 +03:00
|
|
|
includestr = " "
|
|
|
|
if credited is not None:
|
2018-12-22 14:47:49 +03:00
|
|
|
includestr = "Competing under " + artistLink(credited) + " (" + pos + ")"
|
2018-12-17 01:56:30 +03:00
|
|
|
pos = ""
|
2019-02-20 23:10:58 +03:00
|
|
|
included = data.get("associated")
|
2018-12-17 01:56:30 +03:00
|
|
|
if included is not None and included != []:
|
|
|
|
includestr = "associated: "
|
2018-12-27 05:09:29 +03:00
|
|
|
includestr += artistLinks(included)
|
2018-12-22 16:06:21 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
html_tracks, _ = module_trackcharts(**filterkeys,max_=15)
|
2018-12-22 16:06:21 +03:00
|
|
|
|
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
html_pulse = module_pulse(**filterkeys,step="year",stepn=1,trail=1)
|
2018-12-16 19:52:13 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
replace = {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),
|
|
|
|
"KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":"",
|
|
|
|
"KEY_TRACKLIST":html_tracks,"KEY_PULSE":html_pulse,
|
|
|
|
"KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos,
|
|
|
|
"KEY_ASSOCIATED":includestr}
|
2019-02-17 16:25:40 +03:00
|
|
|
|
|
|
|
return (replace,pushresources)
|