show artist decade in genres

+ assign default artist separators if db is empty
+ add instrumental to album version
+ check if album is a single by checking og_title and current title
+ hard code juice wrld artist name in model
+ set album aritst to first artist if track has no album artist
+ rewrite get_base_album_title regex to use existing album versions
+ misc
This commit is contained in:
mungai-njoroge
2023-09-04 11:01:03 +03:00
parent 5ff3e5d28a
commit 83bbe69550
9 changed files with 93 additions and 54 deletions
+5 -12
View File
@@ -1,6 +1,6 @@
import re
from app.enums.album_versions import AlbumVersionEnum
from app.enums.album_versions import AlbumVersionEnum, get_all_keywords
from app.settings import SessionVarKeys, get_flag
@@ -9,14 +9,13 @@ def split_artists(src: str):
Splits a string of artists into a list of artists.
"""
separators: set = get_flag(SessionVarKeys.ARTIST_SEPARATORS)
# separators = separators.union({","})
for sep in separators:
src = src.replace(sep, ",")
artists = src.split(",")
artists = [a.strip() for a in artists]
return [a.strip() for a in artists]
return [a for a in artists if a]
def parse_artist_from_filename(title: str):
@@ -97,12 +96,12 @@ def parse_feat_from_title(title: str) -> tuple[list[str], str]:
return artists, new_title
def get_base_album_title(string) -> tuple[str, str | None]:
def get_base_album_title(string: str) -> tuple[str, str | None]:
"""
Extracts the base album title from a string.
"""
pattern = re.compile(
r"\s*(\(|\[)[^\)\]]*?(version|remaster|deluxe|edition|expanded|anniversary)[^\)\]]*?(\)|\])$",
rf"\s*(\(|\[)[^\)\]]*?({get_all_keywords()})[^\)\]]*?(\)|\])$",
re.IGNORECASE,
)
# TODO: Fix "Redundant character escape '\]' in RegExp "
@@ -205,9 +204,3 @@ def clean_title(title: str) -> str:
rem_2 = remove_hyphen_remasters(title)
return rem_1 if len(rem_2) > len(rem_1) else rem_2
# if "[" in title or "(" in title:
# return remove_bracketed_remaster(title)
#
# if "-" in title:
# return remove_hyphen_remasters(title)