Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detection of "feat. X" parts in parentheses; Fix #5436 #5437

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beets/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
)


_instances = {}

Check failure on line 293 in beets/plugins.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Need type annotation for "_instances" (hint: "_instances: Dict[<type>, <type>] = ...")


def find_plugins():
Expand Down Expand Up @@ -518,7 +518,7 @@
feat_words = ["ft", "featuring", "feat", "feat.", "ft."]
if for_artist:
feat_words += ["with", "vs", "and", "con", "&"]
return r"(?<=\s)(?:{})(?=\s)".format(
return r"(?<=[\s(\[])(?:{})(?=\s)".format(
"|".join(re.escape(x) for x in feat_words)
)

Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ New features:

Bug fixes:

* The detection of a "feat. X" part now also matches such parts if they are in
parentheses or brackets. :bug:`5436`
* Improve naming of temporary files by separating the random part with the file extension.
* Fix the ``auto`` value for the :ref:`reflink` config option.
* Fix lyrics plugin only getting part of the lyrics from ``Genius.com`` :bug:`4815`
Expand Down
5 changes: 5 additions & 0 deletions test/plugins/test_ftintitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,10 @@ def test_contains_feat(self):
assert ftintitle.contains_feat("Alice & Bob")
assert ftintitle.contains_feat("Alice and Bob")
assert ftintitle.contains_feat("Alice With Bob")
assert ftintitle.contains_feat("Alice (ft. Bob)")
assert ftintitle.contains_feat("Alice (feat. Bob)")
assert ftintitle.contains_feat("Alice [ft. Bob]")
assert ftintitle.contains_feat("Alice [feat. Bob]")
assert not ftintitle.contains_feat("Alice defeat Bob")
assert not ftintitle.contains_feat("Aliceft.Bob")
assert not ftintitle.contains_feat("Alice (defeat Bob)")
Loading