import urllib import json def replacedict(keys,dbport): from utilities import getArtistInfo, getTrackInfo from htmlgenerators import clean, artistLink, artistLinks, trackLink, scrobblesTrackLink, keysToUrl, pickKeys, getTimeDesc clean(keys) limitkeys = pickKeys(keys,"artist","title") info = getTrackInfo(keys.getall("artist"),keys.get("title")) imgurl = info.get("image") desc = info.get("info") response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/trackinfo?" + keysToUrl(limitkeys)) db_data = json.loads(response.read()) scrobblesnum = str(db_data["scrobbles"]) pos = "#" + str(db_data["position"]) response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + keysToUrl(limitkeys)) db_data = json.loads(response.read()) scrobbles = db_data["list"] # build list html = "
" + getTimeDesc(s["time"]) + " | " html += "" + artistLinks(s["artists"]) + " | " html += "" + trackLink({"artists":s["artists"],"title":s["title"]}) + " | " html += "