Improve title normalization in discography merge

Updated the normalize_title function to remove unicode accents using NFD normalization and filtering non-spacing marks. This enhances title comparison by handling accented characters more robustly.
This commit is contained in:
Broque Thomas 2026-01-06 07:10:04 -08:00
parent a23b033d37
commit e5457c0214

View file

@ -22373,7 +22373,15 @@ def merge_discography_data(owned_releases, spotify_discography):
def normalize_title(title):
"""Normalize title for comparison"""
import re
normalized = title.lower().strip()
import unicodedata
# Normalize unicode characters to decomposed form (NFD)
normalized = unicodedata.normalize('NFD', title)
# Filter out non-spacing mark characters (accents)
normalized = "".join(c for c in normalized if unicodedata.category(c) != 'Mn')
# Standard normalization
normalized = normalized.lower().strip()
normalized = re.sub(r'[^\w\s]', '', normalized)
normalized = re.sub(r'\s+', ' ', normalized)
return normalized.strip()