import urllib import json def replacedict(keys,dbport): from utilities import getArtistInfo #hand down the since and from arguments extrakeys = urllib.parse.urlencode(keys,quote_via=urllib.parse.quote,safe="/") response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/charts/artists?" + extrakeys) db_data = json.loads(response.read()) charts = db_data["list"][:50] topartist = charts[0]["artist"] info = getArtistInfo(topartist) imgurl = info.get("image") response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/scrobbles?" + extrakeys) db_data = json.loads(response.read()) scrobblelist = db_data["list"] scrobbles = len(scrobblelist) html = "
" html += "" + e["artist"] + "" html += " | " + str(e["scrobbles"]) + " |