configure to allow updating artist separators

+ remove ampersand from default
+ misc
This commit is contained in:
mungai-njoroge 2023-08-25 20:09:50 +03:00
parent 71cab5f5ea
commit 9972f64e8c
7 changed files with 20 additions and 10 deletions

View File

@ -208,9 +208,18 @@ def set_setting():
sdb.set_setting(key, value) sdb.set_setting(key, value)
if mapp[key] is not False: flag = mapp[key]
flag = mapp[key]
set_flag(flag, value) if key == "artist_separators":
reload_all_for_set_setting() value = str(value).split(",")
value = set(value)
set_flag(flag, value)
reload_all_for_set_setting()
# if value is a set, convert it to a string
# (artist_separators)
if type(value) == set:
value = ",".join(value)
return {"result": value} return {"result": value}

View File

@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS settings (
id integer PRIMARY KEY, id integer PRIMARY KEY,
root_dirs text NOT NULL, root_dirs text NOT NULL,
exclude_dirs text, exclude_dirs text,
artist_separators text NOT NULL default '/,;,&', artist_separators text NOT NULL default '/,;',
extract_feat integer NOT NULL DEFAULT 1, extract_feat integer NOT NULL DEFAULT 1,
remove_prod integer NOT NULL DEFAULT 1, remove_prod integer NOT NULL DEFAULT 1,
clean_album_title integer NOT NULL DEFAULT 1, clean_album_title integer NOT NULL DEFAULT 1,

View File

@ -137,7 +137,7 @@ def load_settings():
db_separators = db_separators.replace(" ", "") db_separators = db_separators.replace(" ", "")
separators = db_separators.split(",") separators = db_separators.split(",")
separators = set(db_separators) separators = set(separators)
FromFlags.ARTIST_SEPARATORS = separators FromFlags.ARTIST_SEPARATORS = separators
# boolean settings # boolean settings

View File

@ -288,7 +288,7 @@ class UpdateAppSettingsTable(Migration):
id integer PRIMARY KEY, id integer PRIMARY KEY,
root_dirs text NOT NULL, root_dirs text NOT NULL,
exclude_dirs text, exclude_dirs text,
artist_separators text NOT NULL default '/,;,&', artist_separators text NOT NULL default '/,;',
extract_feat integer NOT NULL DEFAULT 1, extract_feat integer NOT NULL DEFAULT 1,
remove_prod integer NOT NULL DEFAULT 1, remove_prod integer NOT NULL DEFAULT 1,
clean_album_title integer NOT NULL DEFAULT 1, clean_album_title integer NOT NULL DEFAULT 1,

View File

@ -168,7 +168,7 @@ class FromFlags:
PERIODIC_SCAN_INTERVAL = 300 # seconds PERIODIC_SCAN_INTERVAL = 300 # seconds
MERGE_ALBUM_VERSIONS = False MERGE_ALBUM_VERSIONS = False
ARTIST_SEPARATORS = {",", "/", ";", "&"} ARTIST_SEPARATORS = set()
# TODO: Find a way to eliminate this class without breaking typings # TODO: Find a way to eliminate this class without breaking typings

View File

@ -38,7 +38,7 @@ class AlbumStore:
albumhashes = set(t.albumhash for t in TrackStore.tracks) albumhashes = set(t.albumhash for t in TrackStore.tracks)
for albumhash in tqdm(albumhashes, desc=f"Loading {instance_key}"): for albumhash in tqdm(albumhashes, desc=f"Loading albums"):
if instance_key != ALBUM_LOAD_KEY: if instance_key != ALBUM_LOAD_KEY:
return return

View File

@ -8,7 +8,8 @@ def split_artists(src: str):
""" """
Splits a string of artists into a list of artists. Splits a string of artists into a list of artists.
""" """
separators = get_flag(ParserFlags.ARTIST_SEPARATORS) separators: set = get_flag(ParserFlags.ARTIST_SEPARATORS)
separators = separators.union({","})
for sep in separators: for sep in separators:
src = src.replace(sep, "߸") src = src.replace(sep, "߸")