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-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
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 )
2019-03-12 13:39:36 +03:00
imgurl = getArtistImage ( filterkeys [ " artist " ] , fast = True )
2019-02-17 16:25:40 +03:00
pushresources = [ { " file " : imgurl , " type " : " image " } ] if imgurl . startswith ( " / " ) else [ ]
2019-03-29 21:44:42 +03:00
2019-02-20 23:10:58 +03:00
data = database . artistInfo ( filterkeys [ " artist " ] )
scrobbles = str ( data [ " scrobbles " ] )
pos = " # " + str ( data [ " position " ] )
2019-03-29 21:44:42 +03:00
2019-04-02 17:53:57 +03:00
html_medals = " "
if " medals " in data and data [ " medals " ] is not None :
if " gold " in data [ " medals " ] :
for y in data [ " medals " ] [ " gold " ] :
2019-04-02 18:50:04 +03:00
html_medals + = " <a title= ' Best Artist in " + str ( y ) + " ' class= ' hidelink medal gold ' href= ' /charts_artists?max=50&in= " + str ( y ) + " ' ><span> " + str ( y ) + " </span></a> "
2019-04-02 17:53:57 +03:00
if " silver " in data [ " medals " ] :
for y in data [ " medals " ] [ " silver " ] :
2019-04-02 18:50:04 +03:00
html_medals + = " <a title= ' Second Best Artist in " + str ( y ) + " ' class= ' hidelink medal silver ' href= ' /charts_artists?max=50&in= " + str ( y ) + " ' ><span> " + str ( y ) + " </span></a> "
2019-04-02 17:53:57 +03:00
if " bronze " in data [ " medals " ] :
for y in data [ " medals " ] [ " bronze " ] :
2019-04-02 18:50:04 +03:00
html_medals + = " <a title= ' Third Best Artist in " + str ( y ) + " ' class= ' hidelink medal bronze ' href= ' /charts_artists?max=50&in= " + str ( y ) + " ' ><span> " + str ( y ) + " </span></a> "
2019-04-02 17:53:57 +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 )
2019-02-20 20:22:45 +03:00
2019-03-29 21:44:42 +03:00
html_tracks , _ = module_trackcharts ( * * filterkeys , max_ = 15 )
2019-04-02 17:53:57 +03:00
2019-03-29 21:44:42 +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 " ] ) ,
2019-04-02 17:53:57 +03:00
" KEY_IMAGEURL " : imgurl , " KEY_DESCRIPTION " : " " , " KEY_MEDALS " : html_medals ,
2019-02-20 23:10:58 +03:00
" KEY_TRACKLIST " : html_tracks , " KEY_PULSE " : html_pulse ,
" KEY_SCROBBLES " : scrobbles , " KEY_POSITION " : pos ,
" KEY_ASSOCIATED " : includestr }
2019-03-29 21:44:42 +03:00
2019-02-17 16:25:40 +03:00
return ( replace , pushresources )