Strip all parentheticals in AcoustID title normalization

This commit is contained in:
Broque Thomas 2026-03-13 21:28:18 -07:00
parent e1a5bf678a
commit e5a6ac7821

View file

@ -38,15 +38,12 @@ def _normalize(text: str) -> str:
if not text:
return ""
s = text.lower().strip()
# Remove common parenthetical suffixes like (Live), (Remastered), (Cover), (Instrumental), etc.
s = re.sub(r'\s*\((?:live|(?:\d{4}\s*)?remaster(?:ed)?(?:\s*\d{4})?|deluxe|bonus|radio\s*edit|single\s*edit|album\s*edit|single\s*version|cover|acoustic|instrumental|original\s*mix|extended\s*mix|club\s*mix|remix|clean|explicit|visualize.*?)\)', '', s, flags=re.IGNORECASE)
# Remove common square bracket suffixes: [Live], [Remastered], [Cover], [Instrumental], etc.
s = re.sub(r'\s*\[(?:live|(?:\d{4}\s*)?remaster(?:ed)?(?:\s*\d{4})?|deluxe|bonus|radio\s*edit|single\s*edit|album\s*edit|single\s*version|cover|acoustic|instrumental|original\s*mix|extended\s*mix|club\s*mix|remix|clean|explicit)\]', '', s, flags=re.IGNORECASE)
# Remove featuring info in parentheses: "(feat. ...)", "(ft. ...)", "(featuring ...)", "(with ...)"
s = re.sub(r'\s*\((?:feat\.?|ft\.?|featuring|w/|with)\s+[^)]*\)', '', s, flags=re.IGNORECASE)
# Remove featuring info in square brackets: "[feat. ...]", "[ft. ...]", "[W/ ...]", "[with ...]"
s = re.sub(r'\s*\[(?:feat\.?|ft\.?|featuring|w/|with)\s+[^\]]*\]', '', s, flags=re.IGNORECASE)
# Remove trailing featuring info: "feat. ...", "ft. ...", "featuring ..."
# Remove ALL parenthetical suffixes — these are metadata annotations, not core title
# Covers: (Live), (Remastered), (Parody of ...), (from "..." Soundtrack), (feat. ...), etc.
s = re.sub(r'\s*\([^)]*\)', '', s)
# Remove ALL square bracket suffixes: [Live], [Remastered], [Deluxe], etc.
s = re.sub(r'\s*\[[^\]]*\]', '', s)
# Remove trailing featuring info not in parentheses: "feat. ...", "ft. ...", "featuring ..."
s = re.sub(r'\s+(?:feat\.?|ft\.?|featuring)\s+.*$', '', s, flags=re.IGNORECASE)
# Remove dash-separated version tags: "- Vocal", "- Instrumental", "- Acoustic", etc.
s = re.sub(r'\s*-\s*(?:vocal|instrumental|acoustic|live|remix|cover|clean|explicit|radio\s*edit|original\s*mix|extended\s*mix|club\s*mix)\s*$', '', s, flags=re.IGNORECASE)