mirror of
https://github.com/krateng/maloja.git
synced 2025-07-31 14:33:50 -04:00
Charts can now bundle artists
This commit is contained in:
parent
2724541592
commit
a9b5236612
31
cleanup.py
31
cleanup.py
@ -90,8 +90,39 @@ class CleanerAgent:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#this is for all the runtime changes (counting Trouble Maker as HyunA for charts etc)
|
||||||
|
class CollectorAgent:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.updateRules()
|
||||||
|
|
||||||
|
def updateRules(self):
|
||||||
|
raw = utilities.parseAllTSV("rules","string","string","string")
|
||||||
|
self.rules_countas = {b:c for [a,b,c] in raw if a=="countas"}
|
||||||
|
self.rules_include = {} #Twice the memory, double the performance! (Yes, we're saving redundant information here, but it's not unelegant if it's within a closed object!)
|
||||||
|
for a in self.rules_countas:
|
||||||
|
self.rules_include[self.rules_countas[a]] = self.rules_include.setdefault(self.rules_countas[a],[]) + [a]
|
||||||
|
|
||||||
|
# this agent needs to be aware of the current id assignment in the main program. but unelegant, but the best way i can think of
|
||||||
|
def updateIDs(self,artistlist):
|
||||||
|
self.rules_countas_id = {artistlist.index(a):artistlist.index(self.rules_countas[a]) for a in self.rules_countas}
|
||||||
|
#self.rules_include_id = {artistlist.index(a):artistlist.index(self.rules_include[a]) for a in self.rules_include}
|
||||||
|
#this needs to take lists into account
|
||||||
|
|
||||||
|
def getCredited(self,artist):
|
||||||
|
if artist in self.rules_countas_id:
|
||||||
|
return self.rules_countas_id[artist]
|
||||||
|
if artist in self.rules_countas:
|
||||||
|
return self.rules_countas[artist]
|
||||||
|
else:
|
||||||
|
return artist
|
||||||
|
|
||||||
|
|
||||||
|
def getCreditedList(self,artists):
|
||||||
|
updatedArtists = []
|
||||||
|
for artist in artists:
|
||||||
|
updatedArtists.append(self.getCredited(artist))
|
||||||
|
return list(set(updatedArtists))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ TRACKS = [] # Format: tuple(frozenset(artist_ref,...),title)
|
|||||||
timestamps = set()
|
timestamps = set()
|
||||||
|
|
||||||
c = CleanerAgent()
|
c = CleanerAgent()
|
||||||
|
sovereign = CollectorAgent()
|
||||||
clients = []
|
clients = []
|
||||||
|
|
||||||
lastsync = 0
|
lastsync = 0
|
||||||
@ -184,6 +185,7 @@ def runserver(DATABASE_PORT):
|
|||||||
#reload()
|
#reload()
|
||||||
#buildh()
|
#buildh()
|
||||||
build_db()
|
build_db()
|
||||||
|
sovereign.updateIDs(ARTISTS)
|
||||||
|
|
||||||
loadAPIkeys()
|
loadAPIkeys()
|
||||||
|
|
||||||
@ -280,7 +282,7 @@ def db_aggregate(by,since=0,to=9999999999):
|
|||||||
charts = {}
|
charts = {}
|
||||||
for s in [scr for scr in SCROBBLES if since < scr[1] < to]:
|
for s in [scr for scr in SCROBBLES if since < scr[1] < to]:
|
||||||
artists = TRACKS[s[0]][0]
|
artists = TRACKS[s[0]][0]
|
||||||
for a in artists:
|
for a in sovereign.getCreditedList(artists):
|
||||||
# this either creates the new entry or increments the existing one
|
# this either creates the new entry or increments the existing one
|
||||||
charts[a] = charts.setdefault(a,0) + 1
|
charts[a] = charts.setdefault(a,0) + 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user