mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Removed some redundant data
This commit is contained in:
parent
4724e45ae1
commit
0de84629bb
20
database.py
20
database.py
@ -21,7 +21,7 @@ TRACKS = [] # Format: tuple(frozenset(artist_ref,...),title)
|
|||||||
### OPTIMIZATION
|
### OPTIMIZATION
|
||||||
SCROBBLESDICT = {} # timestamps to scrobble mapping
|
SCROBBLESDICT = {} # timestamps to scrobble mapping
|
||||||
STAMPS = [] # sorted
|
STAMPS = [] # sorted
|
||||||
STAMPS_SET = set() # as set for easier check if exists
|
#STAMPS_SET = set() # as set for easier check if exists
|
||||||
|
|
||||||
cla = CleanerAgent()
|
cla = CleanerAgent()
|
||||||
coa = CollectorAgent()
|
coa = CollectorAgent()
|
||||||
@ -68,9 +68,8 @@ def getTrackObject(o):
|
|||||||
|
|
||||||
|
|
||||||
def createScrobble(artists,title,time,volatile=False):
|
def createScrobble(artists,title,time,volatile=False):
|
||||||
while (time in STAMPS_SET):
|
while (time in SCROBBLESDICT):
|
||||||
time += 1
|
time += 1
|
||||||
STAMPS_SET.add(time)
|
|
||||||
i = getTrackID(artists,title)
|
i = getTrackID(artists,title)
|
||||||
obj = (i,time,volatile) # if volatile generated, we simply pretend we have already saved it to disk
|
obj = (i,time,volatile) # if volatile generated, we simply pretend we have already saved it to disk
|
||||||
#SCROBBLES.append(obj)
|
#SCROBBLES.append(obj)
|
||||||
@ -83,12 +82,12 @@ def createScrobble(artists,title,time,volatile=False):
|
|||||||
|
|
||||||
|
|
||||||
def readScrobble(artists,title,time):
|
def readScrobble(artists,title,time):
|
||||||
while (time in STAMPS_SET):
|
while (time in SCROBBLESDICT):
|
||||||
time += 1
|
time += 1
|
||||||
STAMPS_SET.add(time)
|
|
||||||
i = getTrackID(artists,title)
|
i = getTrackID(artists,title)
|
||||||
obj = (i,time,True)
|
obj = (i,time,True)
|
||||||
SCROBBLES.append(obj)
|
SCROBBLES.append(obj)
|
||||||
|
SCROBBLESDICT[time] = obj
|
||||||
#STAMPS.append(time)
|
#STAMPS.append(time)
|
||||||
|
|
||||||
|
|
||||||
@ -695,7 +694,7 @@ def build_db():
|
|||||||
TRACKS = []
|
TRACKS = []
|
||||||
|
|
||||||
|
|
||||||
|
# parse files
|
||||||
db = parseAllTSV("scrobbles","int","string","string",escape=False)
|
db = parseAllTSV("scrobbles","int","string","string",escape=False)
|
||||||
for sc in db:
|
for sc in db:
|
||||||
artists = sc[1].split("␟")
|
artists = sc[1].split("␟")
|
||||||
@ -705,15 +704,14 @@ def build_db():
|
|||||||
readScrobble(artists,title,time)
|
readScrobble(artists,title,time)
|
||||||
|
|
||||||
|
|
||||||
|
# optimize database
|
||||||
SCROBBLES.sort(key = lambda tup: tup[1])
|
SCROBBLES.sort(key = lambda tup: tup[1])
|
||||||
|
#SCROBBLESDICT = {obj[1]:obj for obj in SCROBBLES}
|
||||||
SCROBBLESDICT = {obj[1]:obj for obj in SCROBBLES}
|
|
||||||
STAMPS = [t for t in SCROBBLESDICT]
|
STAMPS = [t for t in SCROBBLESDICT]
|
||||||
STAMPS.sort()
|
STAMPS.sort()
|
||||||
register_scrobbletime(STAMPS[0])
|
|
||||||
|
|
||||||
#print(SCROBBLESDICT)
|
# inform malojatime module about earliest scrobble
|
||||||
#print(STAMPS)
|
register_scrobbletime(STAMPS[0])
|
||||||
|
|
||||||
# get extra artists with zero scrobbles from countas rules
|
# get extra artists with zero scrobbles from countas rules
|
||||||
for artist in coa.getAllArtists():
|
for artist in coa.getAllArtists():
|
||||||
|
Loading…
Reference in New Issue
Block a user