mirror of
https://github.com/simon987/music-graph-scripts.git
synced 2025-04-19 02:16:47 +00:00
Sort name for autocomplete
This commit is contained in:
parent
6460e98ce0
commit
a70b9ffa61
@ -2,7 +2,7 @@ import csv
|
|||||||
import json
|
import json
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
|
|
||||||
from task_tracker_drone.src.tt_drone.api import TaskTrackerApi, Worker
|
from task_tracker_drone.src.tt_drone.api import TaskTrackerApi, Worker, LOG_TRACE
|
||||||
|
|
||||||
TT_API_URL = "https://tt.simon987.net/api"
|
TT_API_URL = "https://tt.simon987.net/api"
|
||||||
TT_PROJECT = 1
|
TT_PROJECT = 1
|
||||||
|
@ -69,7 +69,7 @@ def patch(lastfm_data):
|
|||||||
with open("repo/lastfm_artist.csv", "w") as out:
|
with open("repo/lastfm_artist.csv", "w") as out:
|
||||||
writer = csv.writer(out)
|
writer = csv.writer(out)
|
||||||
writer.writerow([
|
writer.writerow([
|
||||||
"id:ID(Artist)", "name", "year:short", ":LABEL", "listeners:int", "playcount:int"
|
"id:ID(Artist)", "name", "sortname", "year:short", "comment", ":LABEL", "listeners:int", "playcount:int"
|
||||||
])
|
])
|
||||||
|
|
||||||
with open("repo/artist.csv") as f:
|
with open("repo/artist.csv") as f:
|
||||||
@ -82,6 +82,8 @@ def patch(lastfm_data):
|
|||||||
row[1],
|
row[1],
|
||||||
row[2],
|
row[2],
|
||||||
row[3],
|
row[3],
|
||||||
|
row[4],
|
||||||
|
row[5],
|
||||||
artist_listeners.get(row[0], (0, 0))[0],
|
artist_listeners.get(row[0], (0, 0))[0],
|
||||||
artist_listeners.get(row[0], (0, 0))[1],
|
artist_listeners.get(row[0], (0, 0))[1],
|
||||||
])
|
])
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import re
|
||||||
|
|
||||||
links = dict()
|
links = dict()
|
||||||
link_types = dict()
|
link_types = dict()
|
||||||
@ -188,14 +189,24 @@ with open("repo/area.csv", "w") as out:
|
|||||||
out_artist = open("repo/artist.csv", "w")
|
out_artist = open("repo/artist.csv", "w")
|
||||||
out_artist_area = open("repo/artist_area.csv", "w")
|
out_artist_area = open("repo/artist_area.csv", "w")
|
||||||
|
|
||||||
out_artist.write("id:ID(Artist),name,year:int,:LABEL\n")
|
out_artist.write("id:ID(Artist),name,sortname,year:int,comment,:LABEL\n")
|
||||||
out_artist_area.write(":START_ID(Artist),:END_ID(Area)\n")
|
out_artist_area.write(":START_ID(Artist),:END_ID(Area)\n")
|
||||||
|
|
||||||
|
ASCII_RE = re.compile(r"[^a-zA-Z0-9.\-!?& ]")
|
||||||
|
ALPHANUM_RE = re.compile(r"[^\w.\-!?& ]")
|
||||||
|
|
||||||
for _, artist in artists.items():
|
for _, artist in artists.items():
|
||||||
|
|
||||||
|
sortname = ASCII_RE.sub("_", artist[2]).upper()
|
||||||
|
if sortname.replace("_", "").strip() == "":
|
||||||
|
sortname = ALPHANUM_RE.sub("_", artist[3]).upper()
|
||||||
|
|
||||||
out_artist.write(",".join((
|
out_artist.write(",".join((
|
||||||
artist[1],
|
artist[1],
|
||||||
'"' + artist[2].replace("\"", "\"\"") + '"',
|
'"' + artist[2].replace("\"", "\"\"") + '"',
|
||||||
|
sortname,
|
||||||
artist[4] if artist[4] != "\\N" else "0",
|
artist[4] if artist[4] != "\\N" else "0",
|
||||||
|
('"' + artist[13].replace("\"", "\"\"") + '"') if artist[13] != "\\N" else "",
|
||||||
"Artist" + (";Group\n" if artist[10] == "2" else "\n")
|
"Artist" + (";Group\n" if artist[10] == "2" else "\n")
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
CREATE INDEX ON :Artist(id);
|
CREATE INDEX ON :Artist(id);
|
||||||
CREATE INDEX ON :Artist(name);
|
CREATE INDEX ON :Artist(sortname);
|
||||||
CREATE INDEX ON :Release(id);
|
CREATE INDEX ON :Release(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user