15 lines
455 B
Python
15 lines
455 B
Python
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}"
|