Skip to content

feat(lastgenre): Add fallback_original#6414

Closed
Nukesor wants to merge 1 commit intobeetbox:masterfrom
Nukesor:lastgenre-fallback_keep_existing
Closed

feat(lastgenre): Add fallback_original#6414
Nukesor wants to merge 1 commit intobeetbox:masterfrom
Nukesor:lastgenre-fallback_keep_existing

Conversation

@Nukesor
Copy link
Contributor

@Nukesor Nukesor commented Mar 5, 2026

Description

Fixes #6318

Adds the fallback_original flag.

When no genres can be found or no genres match the canonical whitelist, setting this to yes will result in existing genres to be preserved, instead of deleting them or setting them to fallback.

This is for people that would rather have a bit of non-canonicalized genre info than fully loose the existing genre data.


@JOJ0 This is the last feature pull request I have in the pipeline ;D
This is more of a QoL feature that is nice to have, but not super important.

In case you think this is too specific, feel free to close the MR and the related issue :)

Cheers and thanks for your work and the reviews!

To Do

  • Documentation.
  • Changelog.
  • Tests.

Copilot AI review requested due to automatic review settings March 5, 2026 09:28
@Nukesor Nukesor requested a review from a team as a code owner March 5, 2026 09:28
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.41%. Comparing base (edbf737) to head (91dbea3).
⚠️ Report is 44 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/lastgenre/__init__.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6414      +/-   ##
==========================================
+ Coverage   69.39%   69.41%   +0.01%     
==========================================
  Files         141      141              
  Lines       18816    18820       +4     
  Branches     3068     3070       +2     
==========================================
+ Hits        13057    13063       +6     
+ Misses       5112     5111       -1     
+ Partials      647      646       -1     
Files with missing lines Coverage Δ
beetsplug/lastgenre/__init__.py 71.37% <60.00%> (+1.15%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the fallback_original configuration flag to the lastgenre plugin, addressing issue #6318. When enabled, it preserves existing genre tags rather than overwriting them with the configured fallback value (or deleting them) in cases where no valid genres can be found or none survive whitelist/canonicalization filtering.

Changes:

  • Added fallback_original config option and integration logic in beetsplug/lastgenre/__init__.py for both the force=True and force=False/cleanup_existing=True code paths.
  • Added two parametrized test cases to cover both the forced and non-forced fallback_original scenarios.
  • Added documentation for the new option in docs/plugins/lastgenre.rst and a changelog entry in docs/changelog.rst.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
beetsplug/lastgenre/__init__.py Adds fallback_original default config and logic to preserve original genres when no valid genre can be resolved
test/plugins/test_lastgenre.py Adds parametrized test cases for fallback_original under both force=True and force=False/cleanup_existing=True
docs/plugins/lastgenre.rst Documents the new fallback_original option
docs/changelog.rst Changelog entry for the new feature

Comment on lines +507 to +508
if genres and self.config["fallback_original"]:
return genres, "fallback + original, force"
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label "fallback + original, force" at line 508 is misleading. This code path is reachable regardless of whether force is set: when force=False and genres is initially empty (no pre-existing genres), and fallback_original=True, the code still reaches line 507 if all lookup stages fail to find any genres. In that scenario the condition evaluates to False (since genres is []), so it's harmless, but the label implies force is always involved which is not true by design. Consider a more neutral label like "fallback + original" that doesn't imply force mode.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Contributor Author

@Nukesor Nukesor Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As copilot correctly deduced, in the case of no-force, but no genres, this path is never reached and must thereby result in a force = true. I will, however, include a force check to make this more clear.

@Nukesor Nukesor force-pushed the lastgenre-fallback_keep_existing branch from f9dc92f to df178c4 Compare March 5, 2026 10:04
Adds the `fallback_original` flag.

When no genres can be found or no genres match the canonical whitelist,
setting this to `yes` will result in existing genres to be preserved, instead
of deleting them or setting them to `fallback`.

This is for people that would rather have a non-canonicalized genre info
than fully loose the existing genre data.
@Nukesor Nukesor force-pushed the lastgenre-fallback_keep_existing branch from df178c4 to 91dbea3 Compare March 5, 2026 10:15
@Nukesor
Copy link
Contributor Author

Nukesor commented Mar 8, 2026

Nevermind. I thought about this a bit, and I'm still not 100% sure about my own usecase.
I'll close this MR for the time being :)

@Nukesor Nukesor closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lastgenre: Allow keeping of non-whitelisted genres instead of deleting them.

2 participants