mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Switched to better delimiters (tab and ASCII31)
This commit is contained in:
parent
4c2266b9d6
commit
2f8720898b
12
database.py
12
database.py
@ -128,17 +128,17 @@ def build_db():
|
|||||||
|
|
||||||
for f in os.listdir("logs/"):
|
for f in os.listdir("logs/"):
|
||||||
|
|
||||||
if not (".csv" in f):
|
if not (".tsv" in f):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logfile = open("logs/" + f)
|
logfile = open("logs/" + f)
|
||||||
for l in logfile:
|
for l in logfile:
|
||||||
|
|
||||||
l = l.replace("\n","")
|
l = l.replace("\n","")
|
||||||
data = l.split(",")
|
data = l.split("\t")
|
||||||
|
|
||||||
## saving album in the scrobbles is supported, but for now we don't use it. It shouldn't be a defining part of the track (same song from Album or EP), but derived information
|
## saving album in the scrobbles is supported, but for now we don't use it. It shouldn't be a defining part of the track (same song from Album or EP), but derived information
|
||||||
artists = data[1].split("/")
|
artists = data[1].split("␟")
|
||||||
#album = data[3]
|
#album = data[3]
|
||||||
title = data[2]
|
title = data[2]
|
||||||
time = int(data[0])
|
time = int(data[0])
|
||||||
@ -251,12 +251,12 @@ def flush():
|
|||||||
|
|
||||||
t = getScrobbleObject(s)
|
t = getScrobbleObject(s)
|
||||||
|
|
||||||
artistss = "/".join(t["artists"])
|
artistss = "␟".join(t["artists"])
|
||||||
timestamp = datetime.date.fromtimestamp(t["time"])
|
timestamp = datetime.date.fromtimestamp(t["time"])
|
||||||
|
|
||||||
entry = ",".join([str(t["time"]),artistss,t["title"]])
|
entry = "\t".join([str(t["time"]),artistss,t["title"]])
|
||||||
|
|
||||||
monthfile = open("logs/" + str(timestamp.year) + "_" + str(timestamp.month) + ".csv","a")
|
monthfile = open("logs/" + str(timestamp.year) + "_" + str(timestamp.month) + ".tsv","a")
|
||||||
monthfile.write(entry)
|
monthfile.write(entry)
|
||||||
monthfile.write("\n")
|
monthfile.write("\n")
|
||||||
monthfile.close()
|
monthfile.close()
|
||||||
|
@ -18,7 +18,7 @@ for l in log:
|
|||||||
(title,extraartists) = cleanup.findartistsintitle(title)
|
(title,extraartists) = cleanup.findartistsintitle(title)
|
||||||
artists = list(set(artists + extraartists))
|
artists = list(set(artists + extraartists))
|
||||||
|
|
||||||
artistsstr = "/".join(artists)
|
artistsstr = "␟".join(artists)
|
||||||
|
|
||||||
|
|
||||||
timeparts = time.split(" ")
|
timeparts = time.split(" ")
|
||||||
@ -28,7 +28,7 @@ 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())
|
||||||
|
|
||||||
entry = ",".join([str(timestamp),artistsstr,title,album])
|
entry = "\t".join([str(timestamp),artistsstr,title,album])
|
||||||
|
|
||||||
|
|
||||||
outputlog.write(entry)
|
outputlog.write(entry)
|
||||||
|
1
logs/.gitignore
vendored
1
logs/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
|
*.tsv
|
||||||
*.csv
|
*.csv
|
||||||
|
Loading…
Reference in New Issue
Block a user