-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix ftintitle plugin to prioritize explicit featuring tokens #6213
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
base: master
Are you sure you want to change the base?
Conversation
- Prioritize explicit featuring tokens (feat, ft, featuring) over generic separators (&, and) when splitting artist names - Prevents incorrect splits like 'Alice & Bob feat Charlie' from splitting on '&' instead of 'feat' - Add test cases to verify the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `beetsplug/ftintitle.py:45-46` </location>
<code_context>
+ re.IGNORECASE,
)
- parts = tuple(s.strip() for s in regex.split(artist, 1))
+ parts = tuple(s.strip() for s in regex_explicit.split(artist, 1))
+ if len(parts) == 2:
+ return parts
+
</code_context>
<issue_to_address>
**issue (bug_risk):** When `for_artist` is False we no longer fall back to generic tokens, which changes previous behavior.
Previously, both artist and non-artist paths used `feat_tokens(for_artist, custom_words)`, so generic separators were still applied when no explicit featuring token was present. Now, when `for_artist` is False and there’s no explicit `feat`/`ft` token, the generic-token regex is never used and we always return `(artist, None)`. If you only want to avoid over-splitting the artist field, consider preserving the generic fallback for the non-artist case by moving that logic outside `if for_artist:` or adding an `else` that calls `feat_tokens(False, custom_words)`.
</issue_to_address>
### Comment 2
<location> `test/plugins/test_ftintitle.py:306-309` </location>
<code_context>
("Alice and Bob", ("Alice", "Bob")),
("Alice With Bob", ("Alice", "Bob")),
("Alice defeat Bob", ("Alice defeat Bob", None)),
+ ("Alice & Bob feat Charlie", ("Alice & Bob", "Charlie")),
+ ("Alice & Bob ft. Charlie", ("Alice & Bob", "Charlie")),
+ ("Alice & Bob featuring Charlie", ("Alice & Bob", "Charlie")),
+ ("Alice and Bob feat Charlie", ("Alice and Bob", "Charlie")),
],
)
</code_context>
<issue_to_address>
**suggestion (testing):** Add a case where both explicit featuring tokens and generic separators appear on the right-hand side of the split
The added tests cover precedence between explicit featuring tokens and `&`/`and` between primary and featuring artists. To fully cover the behavior, also add a case like `"Alice & Bob feat Charlie & Dave" -> ("Alice & Bob", "Charlie & Dave")` (and possibly `and`/`with` variants) to confirm that, once an explicit token is found, any generic separators to its right remain part of the featuring artist rather than causing another split.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| parts = tuple(s.strip() for s in regex_explicit.split(artist, 1)) | ||
| if len(parts) == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): When for_artist is False we no longer fall back to generic tokens, which changes previous behavior.
Previously, both artist and non-artist paths used feat_tokens(for_artist, custom_words), so generic separators were still applied when no explicit featuring token was present. Now, when for_artist is False and there’s no explicit feat/ft token, the generic-token regex is never used and we always return (artist, None). If you only want to avoid over-splitting the artist field, consider preserving the generic fallback for the non-artist case by moving that logic outside if for_artist: or adding an else that calls feat_tokens(False, custom_words).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6213 +/- ##
=======================================
Coverage 67.90% 67.90%
=======================================
Files 137 137
Lines 18689 18694 +5
Branches 3160 3162 +2
=======================================
+ Hits 12690 12695 +5
Misses 5332 5332
Partials 667 667
🚀 New features to boost your workflow:
|
|
The changes make sense from my perspective. @henry-oberholtzer @EmberLightVFX Do you mind reviewing this too? I have the feeling that there might be something I'm missing since I'm not too familiar with the |
Description
Fixes an issue where the ftintitle plugin would incorrectly split artist names on generic separators (&, and) when explicit featuring tokens (feat, ft, featuring) were also present.
Example
Alice & Bob feat Charliecould split on&→("Alice", "Bob feat Charlie")Alice & Bob feat Charliesplits onfeat→("Alice & Bob", "Charlie")✓Changes
split_on_feat()to try explicit featuring tokens firstTo Do