def instructions(keys): from utilities import getArtistImage from urihandler import compose_querystring, uri_to_internal from htmlmodules import module_artistcharts, module_filterselection from malojatime import range_desc _, timekeys, _, amountkeys = uri_to_internal(keys) limitstring = timekeys["timerange"].desc(prefix=True) html_filterselector = module_filterselection(keys) html_charts, rep = module_artistcharts(**amountkeys, **timekeys) if rep is not None: imgurl = getArtistImage(rep) else: imgurl = "" pushresources = [{ "file": imgurl, "type": "image" }] if imgurl.startswith("/") else [] replace = { "KEY_TOPARTIST_IMAGEURL": imgurl, "KEY_ARTISTLIST": html_charts, "KEY_RANGE": limitstring, "KEY_FILTERSELECTOR": html_filterselector } return (replace, pushresources)
def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, artistLinks, trackLink from urihandler import compose_querystring, uri_to_internal from htmlmodules import module_scrobblelist, module_filterselection from malojatime import range_desc filterkeys, timekeys, _, amountkeys = uri_to_internal(keys) # describe the scope limitstring = "" if filterkeys.get("track") is not None: limitstring += "of " + trackLink(filterkeys["track"]) + " " limitstring += "by " + artistLinks(filterkeys["track"]["artists"]) 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") if moreartists != []: limitstring += " <span class='extra'>including " + artistLinks(moreartists) + "</span>" limitstring += " " + timekeys["timerange"].desc(prefix=True) html_filterselector = module_filterselection(keys) html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys) # get image if filterkeys.get("track") is not None: imgurl = getTrackImage(filterkeys.get("track")["artists"],filterkeys.get("track")["title"],fast=True) elif filterkeys.get("artist") is not None: imgurl = getArtistImage(keys.get("artist"),fast=True) elif rep is not None: imgurl = getTrackImage(rep["artists"],rep["title"],fast=True) else: imgurl = "" pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] replace = {"KEY_SCROBBLELIST":html, "KEY_SCROBBLES":str(amount), "KEY_IMAGEURL":imgurl, "KEY_LIMITS":limitstring, "KEY_FILTERSELECTOR":html_filterselector} return (replace,pushresources)
def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink from urihandler import compose_querystring, uri_to_internal from htmlmodules import module_trackcharts, module_filterselection from malojatime import range_desc filterkeys, timekeys, _, amountkeys = uri_to_internal(keys) if len(filterkeys) == 0: toptrackslink = "<a href='/top_tracks'><span>View #1 Tracks</span></a>" else: toptrackslink = "" limitstring = "" html_filterselector = module_filterselection(keys) html_charts, rep = module_trackcharts(**amountkeys, **timekeys, **filterkeys) if filterkeys.get("artist") is not None: imgurl = getArtistImage(filterkeys.get("artist")) limitstring = "by " + artistLink(filterkeys.get("artist")) elif rep is not None: imgurl = getTrackImage(rep["artists"], rep["title"]) else: imgurl = "" limitstring += " " + timekeys["timerange"].desc(prefix=True) pushresources = [{ "file": imgurl, "type": "image" }] if imgurl.startswith("/") else [] replace = { "KEY_TOPARTIST_IMAGEURL": imgurl, "KEY_TRACKLIST": html_charts, "KEY_LIMITS": limitstring, "KEY_FILTERSELECTOR": html_filterselector, "TOP_TRACKS_LINK": toptrackslink, } return (replace, pushresources)
def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink from urihandler import compose_querystring, uri_to_internal from htmlmodules import module_toptracks, module_filterselection from malojatime import range_desc filterkeys, timekeys, delimitkeys, _ = uri_to_internal(keys) limitstring = "" html_filterselector = module_filterselection(keys, delimit=True) html_charts, rep = module_toptracks( **timekeys, **delimitkeys) ### **filterkeys implementing? #if filterkeys.get("artist") is not None: # imgurl = getArtistImage(filterkeys.get("artist")) # limitstring = "by " + artistLink(filterkeys.get("artist")) if rep is not None: imgurl = getTrackImage(rep["artists"], rep["title"]) else: imgurl = "" limitstring += " " + timekeys["timerange"].desc(prefix=True) pushresources = [{ "file": imgurl, "type": "image" }] if imgurl.startswith("/") else [] replace = { "KEY_TOPTRACK_IMAGEURL": imgurl, "KEY_TRACKLIST": html_charts, "KEY_LIMITS": limitstring, "KEY_FILTERSELECTOR": html_filterselector } return (replace, pushresources)
def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink from urihandler import compose_querystring, uri_to_internal, internal_to_uri from htmlmodules import module_performance, module_filterselection from malojatime import range_desc, delimit_desc filterkeys, timekeys, delimitkeys, paginatekeys = uri_to_internal(keys) #equivalent pulse chart pulselink_keys = internal_to_uri({ **filterkeys, **timekeys, **delimitkeys, **paginatekeys }) pulselink = "/pulse?" + compose_querystring(pulselink_keys) pulselink = "<a href=\"" + pulselink + "\"><span>View Pulse</span></a>" # describe the scope (and creating a key for the relevant artist or track) limitstring = "" #limitkey = {} if filterkeys.get("track") is not None: #limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")} limitstring += "of " + trackLink(filterkeys["track"]) + " " limitstring += "by " + artistLinks(filterkeys["track"]["artists"]) elif filterkeys.get("artist") is not None: #limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None) limitstring += "of " + artistLink(filterkeys.get("artist")) # associated are counted by default data = database.artistInfo(filterkeys["artist"]) moreartists = data["associated"] if moreartists != []: limitstring += " <span class='extra'>including " + artistLinks( moreartists) + "</span>" limitstring += " " + timekeys["timerange"].desc(prefix=True) delimitstring = delimit_desc(**delimitkeys) html_filterselector = module_filterselection(keys, delimit=True) # get image if filterkeys.get("track") is not None: imgurl = getTrackImage( filterkeys.get("track")["artists"], filterkeys.get("track")["title"]) elif filterkeys.get("artist") is not None: imgurl = getArtistImage(keys.get("artist")) else: imgurl = "" pushresources = [{ "file": imgurl, "type": "image" }] if imgurl.startswith("/") else [] html_performance = module_performance(**filterkeys, **timekeys, **delimitkeys, **paginatekeys) replace = { "KEY_PULSE_LINK": pulselink, "KEY_PERFORMANCE_TABLE": html_performance, "KEY_IMAGEURL": imgurl, "KEY_LIMITS": limitstring, "KEY_PULSEDETAILS": delimitstring, "KEY_FILTERSELECTOR": html_filterselector } return (replace, pushresources)