diff --git a/htmlgenerators.py b/htmlgenerators.py index bb6e39a..4073ef4 100644 --- a/htmlgenerators.py +++ b/htmlgenerators.py @@ -14,38 +14,75 @@ def entity_column(element,counting=[],image=None): if "artists" in element: # track - html += "" + artistLinks(element["artists"]) + "" - html += "" + trackLink({"artists":element["artists"],"title":element["title"]}) + "" + html += "" + html_links(element["artists"]) + "" + html += "" + html_link(element) + "" else: # artist - html += "" + artistLink(element) + html += "" + html_link(element) if (counting != []): - html += " incl. " + ", ".join([artistLink(a) for a in counting]) + "" + html += " incl. " + html_links(counting) + "" html += "" return html -def artistLink(name): - return "" + name + "" +def uri_query(entity): + if "artists" in entity: + #track + return "title=" + urllib.parse.quote(entity["title"]) \ + + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in entity["artists"]]) + else: + #artist + return "artist=" + urllib.parse.quote(entity) + +# returns the address of the track / artist page +def link_address(entity): + if "artists" in entity: + #track + return "/track?" + uri_query(entity) + else: + #artist + return "/artist?" + uri_query(entity) + +#returns linked name +def html_link(entity): + if "artists" in entity: + #track + name = entity["title"] + else: + #artist + name = entity + return "" + name + "" + +def html_links(entities): + return ", ".join([html_link(e) for e in entities]) + +# DEPRECATED +def artistLink(name): + return html_link(name) + #return "" + name + "" + +# DEPRECATED def artistLinks(artists): return ", ".join([artistLink(a) for a in artists]) #def trackLink(artists,title): +# DEPRECATED def trackLink(track): - artists,title = track["artists"],track["title"] - return "" + title + "" + return html_link(track) + #artists,title = track["artists"],track["title"] + #return "" + title + "" #def scrobblesTrackLink(artists,title,timekeys,amount=None,pixels=None): def scrobblesTrackLink(track,timekeys,amount=None,percent=None): artists,title = track["artists"],track["title"] inner = str(amount) if amount is not None else "
" - return "" + inner + "" + return "" + inner + "" def scrobblesArtistLink(artist,timekeys,amount=None,percent=None,associated=False): inner = str(amount) if amount is not None else "
" askey = "&associated" if associated else "" - return "" + inner + "" + return "" + inner + "" def scrobblesLink(timekeys,amount=None,percent=None,artist=None,track=None,associated=False): if track is not None: return scrobblesTrackLink(track,timekeys,amount,percent) diff --git a/htmlmodules.py b/htmlmodules.py index 39a7e05..ed12084 100644 --- a/htmlmodules.py +++ b/htmlmodules.py @@ -361,19 +361,12 @@ def module_artistcharts_tiles(**kwargs): if e is not None: - #rank = i if e["scrobbles"] != rnk[1] else rnk[0] - #rnk = (rank,e["scrobbles"]) - rank = "#" + str(e["rank"]) - #image = "/image?artist=" + urllib.parse.quote(e["artist"]) - image = getArtistImage(e["artist"],fast=True) - link = artistLink(e["artist"]) + html += "" \ + + "" + "#" + str(e["rank"]) + " " + html_link(e["artist"]) + "" else: - rank = "" - image = "" - link = "" - - - html += """""" + rank + " " + link + "" + html += " " i += 1 @@ -417,18 +410,12 @@ def module_trackcharts_tiles(**kwargs): if e is not None: - #rank = i if e["scrobbles"] != rnk[1] else rnk[0] - #rnk = (rank,e["scrobbles"]) - rank = "#" + str(e["rank"]) - #image = "/image?title=" + urllib.parse.quote(e["track"]["title"]) + "&" + "&".join(["artist=" + urllib.parse.quote(a) for a in e["track"]["artists"]]) - image = getTrackImage(e["track"]["artists"],e["track"]["title"],fast=True) - link = trackLink(e["track"]) + html += "" \ + + "" + "#" + str(e["rank"]) + " " + html_link(e["track"]) + "" else: - rank = "" - image = "" - link = "" - - html += """""" + rank + " " + link + "" + html += " " i += 1 diff --git a/scrobblers/chromium-generic/background.js b/scrobblers/chromium-generic/background.js index fbaceb7..7ed9f01 100644 --- a/scrobblers/chromium-generic/background.js +++ b/scrobblers/chromium-generic/background.js @@ -71,10 +71,9 @@ function onTabUpdated(tabId, changeInfo, tab) { function onTabRemoved(tabId,removeInfo) { - console.log(tabId + " closed") if (tabManagers.hasOwnProperty(tabId)) { page = tabManagers[tabId].page - console.log("this tab was " + page + ", now removing manager") + console.log("closed tab was " + page + ", now removing manager") tabManagers[tabId].stopPlayback("","") //in case we want to scrobble the playing track delete tabManagers[tabId] }