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:
@@ -472,15 +472,30 @@ class ArtistImporter:
|
||||
token: str
|
||||
for token in ArtistImporter.DELIMITER_PATTERN.split(
|
||||
side):
|
||||
name: str = token.strip()
|
||||
placeholder = ""
|
||||
original: str
|
||||
for placeholder, original in placeholders.items():
|
||||
name = name.replace(placeholder, original)
|
||||
name: str = ArtistImporter.__restore_protected(
|
||||
token.strip(), placeholders)
|
||||
if name != "":
|
||||
pairs.append((name, role))
|
||||
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
|
||||
def resolve_artist_identity(name: str) -> tuple[str, str]:
|
||||
"""Resolve the dedup key and the stored spelling of a name.
|
||||
|
||||
Reference in New Issue
Block a user