1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Timestamps are now unique identifiers of a scrobble

This commit is contained in:
Krateng
2018-11-29 16:05:44 +01:00
parent 08caeec8e0
commit 4ec2f4a118
4 changed files with 33 additions and 8 deletions

View File

@@ -1,11 +1,14 @@
import sys, os, datetime, re, cleanup
from cleanup import *
from utilities import *
log = open(sys.argv[1])
outputlog = open(sys.argv[2],"w")
c = CleanerAgent()
stamps = [99999999999999]
for l in log:
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())
## 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])