mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Timestamps are now unique identifiers of a scrobble
This commit is contained in:
parent
08caeec8e0
commit
4ec2f4a118
14
database.py
14
database.py
@ -12,6 +12,8 @@ SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
|
|||||||
ARTISTS = [] # Format: artist
|
ARTISTS = [] # Format: artist
|
||||||
TRACKS = [] # Format: tuple(frozenset(artist_ref,...),title)
|
TRACKS = [] # Format: tuple(frozenset(artist_ref,...),title)
|
||||||
|
|
||||||
|
timestamps = set()
|
||||||
|
|
||||||
c = CleanerAgent()
|
c = CleanerAgent()
|
||||||
|
|
||||||
lastsync = 0
|
lastsync = 0
|
||||||
@ -43,13 +45,17 @@ def getTrackObject(o):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def createScrobble(artists,title,time):
|
def createScrobble(artists,title,time):
|
||||||
i = getTrackID(artists,title)
|
while (time in timestamps):
|
||||||
|
time += 1
|
||||||
|
i = getTrackID(artists,title)
|
||||||
obj = (i,time,False)
|
obj = (i,time,False)
|
||||||
SCROBBLES.append(obj)
|
SCROBBLES.append(obj)
|
||||||
|
|
||||||
def readScrobble(artists,title,time):
|
def readScrobble(artists,title,time):
|
||||||
i = getTrackID(artists,title)
|
while (time in timestamps):
|
||||||
|
time += 1
|
||||||
|
i = getTrackID(artists,title)
|
||||||
obj = (i,time,True)
|
obj = (i,time,True)
|
||||||
SCROBBLES.append(obj)
|
SCROBBLES.append(obj)
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import sys, os, datetime, re, cleanup
|
import sys, os, datetime, re, cleanup
|
||||||
from cleanup import *
|
from cleanup import *
|
||||||
|
from utilities import *
|
||||||
|
|
||||||
|
|
||||||
log = open(sys.argv[1])
|
log = open(sys.argv[1])
|
||||||
|
|
||||||
outputlog = open(sys.argv[2],"w")
|
outputlog = open(sys.argv[2],"w")
|
||||||
|
|
||||||
|
|
||||||
c = CleanerAgent()
|
c = CleanerAgent()
|
||||||
|
stamps = [99999999999999]
|
||||||
|
|
||||||
for l in log:
|
for l in log:
|
||||||
l = l.replace("\n","")
|
l = l.replace("\n","")
|
||||||
@ -29,6 +32,23 @@ for l in log:
|
|||||||
|
|
||||||
timestamp = int(datetime.datetime(int(timeparts[2]),months[timeparts[1]],int(timeparts[0]),int(h),int(m)).timestamp())
|
timestamp = int(datetime.datetime(int(timeparts[2]),months[timeparts[1]],int(timeparts[0]),int(h),int(m)).timestamp())
|
||||||
|
|
||||||
|
|
||||||
|
## We prevent double timestamps in the database creation, so we technically don't need them in the files
|
||||||
|
## however since the conversion from lastfm to maloja is a one-time, thing, we should take any effort to make the file as good as possible
|
||||||
|
if (timestamp < stamps[-1]):
|
||||||
|
pass
|
||||||
|
elif (timestamp == stamps[-1]):
|
||||||
|
timestamp -= 1
|
||||||
|
else:
|
||||||
|
while(timestamp in stamps):
|
||||||
|
timestamp -= 1
|
||||||
|
|
||||||
|
if (timestamp < stamps[-1]):
|
||||||
|
stamps.append(timestamp)
|
||||||
|
else:
|
||||||
|
stamps.insert(0,timestamp)
|
||||||
|
|
||||||
|
|
||||||
entry = "\t".join([str(timestamp),artistsstr,title,album])
|
entry = "\t".join([str(timestamp),artistsstr,title,album])
|
||||||
|
|
||||||
|
|
||||||
|
1
rules/.gitignore
vendored
1
rules/.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
*.tsv
|
*.tsv
|
||||||
!examplerules.tsv
|
|
||||||
|
@ -3,14 +3,14 @@ This folder can have any number of tsv files to group your rules
|
|||||||
The first column defines the type of the rule:
|
The first column defines the type of the rule:
|
||||||
notanartist Defines strings that can appear behind "feat" in a song title, but denote additional information about the track instead of another artist.
|
notanartist Defines strings that can appear behind "feat" in a song title, but denote additional information about the track instead of another artist.
|
||||||
Second column is the string
|
Second column is the string
|
||||||
belongtogether Defines an artist with an ampersand in their name. Otherwise, amerpsands are interpreted as denoting two different artists (except when there are no spaces).
|
belongtogether Defines an artist with an ampersand or other delimiter in their name. Otherwise, the artist string will be interpreted as two different artists (except when there are no spaces).
|
||||||
Second column is the full name of the artist
|
Second column is the full name of the artist
|
||||||
replacetitle Defines an alternative spelling of a track title that should be replaced.
|
replacetitle Defines an alternative spelling of a track title that should be replaced.
|
||||||
Second column is the 'wrong' spelling
|
Second column is the 'wrong' spelling
|
||||||
Third column the correct spelling
|
Third column the correct spelling
|
||||||
replaceartist Defines and alternative spelling of an artist that should be replaced
|
replaceartist Defines and alternative spelling of an artist that should be replaced
|
||||||
Second column is the 'wrong' spelling
|
Second column is the 'wrong' spelling
|
||||||
Third column the correct spelling. Use ␟ if the spelling should correct to a several artists
|
Third column the correct spelling. Use ␟ if the spelling should correct to several artists
|
||||||
countas Defines an artist that should be counted together with another artist for chart statistics etc.
|
countas Defines an artist that should be counted together with another artist for chart statistics etc.
|
||||||
This will not change the separation in the database and all effects of this rule will disappear as soon as it is no longer active.
|
This will not change the separation in the database and all effects of this rule will disappear as soon as it is no longer active.
|
||||||
Second column is the artist
|
Second column is the artist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user