Extract the protected name restoration out of the credit parser

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 22:38:38 +08:00
co-authored by Claude Opus 5
parent 2ea23d9bce
commit 693dbccc9d
@@ -472,15 +472,30 @@ class ArtistImporter:
token: str token: str
for token in ArtistImporter.DELIMITER_PATTERN.split( for token in ArtistImporter.DELIMITER_PATTERN.split(
side): side):
name: str = token.strip() name: str = ArtistImporter.__restore_protected(
placeholder = "" token.strip(), placeholders)
original: str
for placeholder, original in placeholders.items():
name = name.replace(placeholder, original)
if name != "": if name != "":
pairs.append((name, role)) pairs.append((name, role))
return pairs return pairs
@staticmethod
def __restore_protected(
name: str, placeholders: dict[str, str]) -> str:
"""Restore the protected artist names in a parsed name.
:param name: A parsed artist name, possibly containing
placeholders.
:param placeholders: The protected artist names, keyed by
the placeholder standing for each of them.
:return: The name with every placeholder replaced by the
protected artist name it stands for.
"""
placeholder: str
original: str
for placeholder, original in placeholders.items():
name = name.replace(placeholder, original)
return name
@staticmethod @staticmethod
def resolve_artist_identity(name: str) -> tuple[str, str]: def resolve_artist_identity(name: str) -> tuple[str, str]:
"""Resolve the dedup key and the stored spelling of a name. """Resolve the dedup key and the stored spelling of a name.