2018-12-27 16:57:25 +03:00
|
|
|
import urllib
|
2019-02-20 20:22:45 +03:00
|
|
|
import database
|
2018-12-27 16:57:25 +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-02-21 11:43:35 +03:00
|
|
|
from htmlgenerators import artistLinks, keysToUrl, KeySplit
|
2019-02-20 20:22:45 +03:00
|
|
|
from htmlmodules import module_scrobblelist, module_pulse
|
2018-12-27 16:57:25 +03:00
|
|
|
|
2019-03-29 21:44:42 +03:00
|
|
|
|
|
|
|
filterkeys, _, _, _ = KeySplit(keys,forceTrack=True)
|
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
track = filterkeys.get("track")
|
2019-03-12 13:39:36 +03:00
|
|
|
imgurl = getTrackImage(track["artists"],track["title"],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 20:22:45 +03:00
|
|
|
data = database.trackInfo(track["artists"],track["title"])
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
scrobblesnum = str(data["scrobbles"])
|
|
|
|
pos = "#" + str(data["position"])
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
|
2019-03-12 14:56:53 +03:00
|
|
|
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100,earlystop=True) # we have the number already from the trackinfo
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-20 20:22:45 +03:00
|
|
|
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
|
|
|
|
|
2018-12-27 16:57:25 +03:00
|
|
|
|
2019-02-20 23:10:58 +03:00
|
|
|
replace = {"KEY_TRACKTITLE":track.get("title"),"KEY_ARTISTS":artistLinks(track.get("artists")),"KEY_SCROBBLES":scrobblesnum,"KEY_POSITION":pos,"KEY_IMAGEURL":imgurl,
|
|
|
|
"KEY_SCROBBLELINK":keysToUrl(keys),
|
|
|
|
"KEY_SCROBBLELIST":html_scrobbles,"KEY_PULSE":html_pulse}
|
2019-03-29 21:44:42 +03:00
|
|
|
|
2019-02-17 16:25:40 +03:00
|
|
|
return (replace,pushresources)
|