A kind of initial commit
This commit is contained in:
14
app/utils/text.py
Normal file
14
app/utils/text.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
|
||||
_WS_RE = re.compile(r"\s+")
|
||||
_FEAT_RE = re.compile(r"\s*[\(\[\-–—]\s*(feat|ft)\.?.*$", re.IGNORECASE)
|
||||
|
||||
|
||||
def normalize_track_signature(name: str, artists: list[str]) -> str:
|
||||
clean_name = _FEAT_RE.sub("", name).strip().lower()
|
||||
clean_name = _WS_RE.sub(" ", clean_name)
|
||||
clean_artists = ",".join(sorted(a.strip().lower() for a in artists if a.strip()))
|
||||
return f"{clean_name}::{clean_artists}"
|
||||
Reference in New Issue
Block a user