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
This commit is contained in:
Šarūnas Nejus 2024-10-02 00:19:38 +01:00 committed by GitHub
commit 03f1205629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View file

@ -37,7 +37,13 @@ def split_on_feat(artist):
def contains_feat(title):
"""Determine whether the title contains a "featured" marker."""
return bool(re.search(plugins.feat_tokens(), title, flags=re.IGNORECASE))
return bool(
re.search(
plugins.feat_tokens(for_artist=False),
title,
flags=re.IGNORECASE,
)
)
def find_feat_part(artist, albumartist):

View file

@ -26,7 +26,9 @@ New features:
Bug fixes:
* The detection of a "feat. X" part now also matches such parts if they are in
* :doc:`plugins/ftintitle`: The detection of a "feat. X" part in a song title does not produce any false
positives caused by words like "and" or "with" anymore. :bug:`5441`
* :doc:`plugins/ftintitle`: 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.

View file

@ -180,9 +180,6 @@ class FtInTitlePluginTest(unittest.TestCase):
assert ftintitle.contains_feat("Alice feat. Bob")
assert ftintitle.contains_feat("Alice feat Bob")
assert ftintitle.contains_feat("Alice featuring Bob")
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]")
@ -190,3 +187,5 @@ class FtInTitlePluginTest(unittest.TestCase):
assert not ftintitle.contains_feat("Alice defeat Bob")
assert not ftintitle.contains_feat("Aliceft.Bob")
assert not ftintitle.contains_feat("Alice (defeat Bob)")
assert not ftintitle.contains_feat("Live and Let Go")
assert not ftintitle.contains_feat("Come With Me")