diff --git a/cleanup.py b/cleanup.py index 2527f2c..662cea5 100644 --- a/cleanup.py +++ b/cleanup.py @@ -157,6 +157,11 @@ class CollectorAgent: def getAllAssociated(self,artist): return self.rules_include.get(artist,[]) + # this function is there to check for artists that we should include in the database even though they never have any scrobble. important to avoid bugs when + # countas rules are declared preemptively + def getAllArtists(self): + return list(set([a for a in self.rules_countas] + [self.rules_countas[a] for a in self.rules_countas])) + diff --git a/database.py b/database.py index 4adb4bf..d3eb14a 100644 --- a/database.py +++ b/database.py @@ -596,6 +596,11 @@ def build_db(): SCROBBLES.sort(key = lambda tup: tup[1]) + # get extra artists with zero scrobbles from countas rules + for artist in coa.getAllArtists(): + if artist not in ARTISTS: + ARTISTS.append(artist) + coa.updateIDs(ARTISTS) global db_rulestate diff --git a/website/artist.py b/website/artist.py index 995a81e..596b1a6 100644 --- a/website/artist.py +++ b/website/artist.py @@ -32,7 +32,7 @@ def replacedict(keys,dbport): response = urllib.request.urlopen("http://localhost:" + str(dbport) + "/charts/tracks?artist=" + urllib.parse.quote(keys["artist"])) db_data = json.loads(response.read()) - maxbar = db_data["list"][0]["scrobbles"] + if db_data["list"] != []: maxbar = db_data["list"][0]["scrobbles"] html = "" for e in db_data["list"]: html += ""