Skip to content

Commit 03f1205

Browse files
authored
ftintitle: Fix false positives in "feat. X" detection in title (#5442)
Fixes #5441 This small change explicitly passes the `for_artist` keyword to the `plugins.feat_tokens` function that constructs the regex for matching existing "feat. X" parts in song titles. Previously, it was not passed and set to the default (`True`), which caused using the pattern intended for the artist field to also be used for the title field. This caused some false positives as shown in #5441
2 parents 04ee041 + 37879d0 commit 03f1205

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Diff for: beetsplug/ftintitle.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ def split_on_feat(artist):
3737

3838
def contains_feat(title):
3939
"""Determine whether the title contains a "featured" marker."""
40-
return bool(re.search(plugins.feat_tokens(), title, flags=re.IGNORECASE))
40+
return bool(
41+
re.search(
42+
plugins.feat_tokens(for_artist=False),
43+
title,
44+
flags=re.IGNORECASE,
45+
)
46+
)
4147

4248

4349
def find_feat_part(artist, albumartist):

Diff for: docs/changelog.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ New features:
2626

2727
Bug fixes:
2828

29-
* The detection of a "feat. X" part now also matches such parts if they are in
29+
* :doc:`plugins/ftintitle`: The detection of a "feat. X" part in a song title does not produce any false
30+
positives caused by words like "and" or "with" anymore. :bug:`5441`
31+
* :doc:`plugins/ftintitle`: The detection of a "feat. X" part now also matches such parts if they are in
3032
parentheses or brackets. :bug:`5436`
3133
* Improve naming of temporary files by separating the random part with the file extension.
3234
* Fix the ``auto`` value for the :ref:`reflink` config option.

Diff for: test/plugins/test_ftintitle.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,12 @@ def test_contains_feat(self):
180180
assert ftintitle.contains_feat("Alice feat. Bob")
181181
assert ftintitle.contains_feat("Alice feat Bob")
182182
assert ftintitle.contains_feat("Alice featuring Bob")
183-
assert ftintitle.contains_feat("Alice & Bob")
184-
assert ftintitle.contains_feat("Alice and Bob")
185-
assert ftintitle.contains_feat("Alice With Bob")
186183
assert ftintitle.contains_feat("Alice (ft. Bob)")
187184
assert ftintitle.contains_feat("Alice (feat. Bob)")
188185
assert ftintitle.contains_feat("Alice [ft. Bob]")
189186
assert ftintitle.contains_feat("Alice [feat. Bob]")
190187
assert not ftintitle.contains_feat("Alice defeat Bob")
191188
assert not ftintitle.contains_feat("Aliceft.Bob")
192189
assert not ftintitle.contains_feat("Alice (defeat Bob)")
190+
assert not ftintitle.contains_feat("Live and Let Go")
191+
assert not ftintitle.contains_feat("Come With Me")

0 commit comments

Comments
 (0)