1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00
maloja/website/track.py

33 lines
1.0 KiB
Python
Raw Normal View History

2018-12-27 16:57:25 +03:00
import urllib
import database
2018-12-27 16:57:25 +03:00
def instructions(keys):
2018-12-28 20:06:09 +03:00
from utilities import getArtistInfo, getTrackInfo
from htmlgenerators import artistLinks, keysToUrl, KeySplit
from htmlmodules import module_scrobblelist, module_pulse
2018-12-27 16:57:25 +03:00
filterkeys, _, _, _ = KeySplit(keys,forceTrack=True)
track = filterkeys.get("track")
imgurl = getTrackInfo(track["artists"],track["title"]).get("image")
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
2018-12-27 16:57:25 +03:00
data = database.trackInfo(track["artists"],track["title"])
scrobblesnum = str(data["scrobbles"])
pos = "#" + str(data["position"])
2018-12-27 16:57:25 +03:00
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100)
2019-02-20 01:18:46 +03:00
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
2018-12-27 16:57:25 +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}
return (replace,pushresources)