diff --git a/beets/plugins.py b/beets/plugins.py index 397c33822..65c181388 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -633,14 +633,16 @@ def send(event: EventType, **arguments: Any) -> list[Any]: def feat_tokens( - for_artist: bool = True, custom_feat_words: list[str] = [] + for_artist: bool = True, custom_feat_words: list[str] | None = None ) -> str: """Return a regular expression that matches phrases like "featuring" that separate a main artist or a song title from secondary artists. The `for_artist` option determines whether the regex should be suitable for matching artist fields (the default) or title fields. """ - feat_words = ["ft", "featuring", "feat", "feat.", "ft."] + custom_feat_words + feat_words = ["ft", "featuring", "feat", "feat.", "ft."] + if isinstance(custom_feat_words, list): + feat_words += custom_feat_words if for_artist: feat_words += ["with", "vs", "and", "con", "&"] return ( diff --git a/beetsplug/ftintitle.py b/beetsplug/ftintitle.py index b1331e893..6837732b2 100644 --- a/beetsplug/ftintitle.py +++ b/beetsplug/ftintitle.py @@ -27,7 +27,9 @@ if TYPE_CHECKING: def split_on_feat( - artist: str, for_artist: bool = True, custom_feat_words: list[str] = [] + artist: str, + for_artist: bool = True, + custom_feat_words: list[str] | None = None, ) -> tuple[str, str | None]: """Given an artist string, split the "main" artist from any artist on the right-hand side of a string like "feat". Return the main @@ -46,7 +48,9 @@ def split_on_feat( return parts -def contains_feat(title: str, custom_feat_words: list[str] = []) -> bool: +def contains_feat( + title: str, custom_feat_words: list[str] | None = None +) -> bool: """Determine whether the title contains a "featured" marker.""" return bool( re.search( @@ -60,7 +64,9 @@ def contains_feat(title: str, custom_feat_words: list[str] = []) -> bool: def find_feat_part( - artist: str, albumartist: str | None, custom_feat_words: list[str] = [] + artist: str, + albumartist: str | None, + custom_feat_words: list[str] | None = None, ) -> str | None: """Attempt to find featured artists in the item's artist fields and return the results. Returns None if no featured artist found.