Skip to content

lastgenre: Album stage fall back to multi-valued albumartists - #6893

Open
JOJ0 wants to merge 4 commits into
masterfrom
lastgenre_album_albumartists_fallback
Open

JOJ0 wants to merge 4 commits into
masterfrom
lastgenre_album_albumartists_fallback

Conversation

@JOJ0

@JOJ0 JOJ0 commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes: #6238

If last.fm returns no album genres for albumartist, fall back to querying the album against each artist in albumartists (falling through to the artist stage if that also yields nothing.)

The album stage reasoning is now slightly more complex and was moved to its own helper method.

To Do

  • Documentation.
  • Changelog.
  • Tests.

@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@JOJ0 JOJ0 changed the title temp commit for cherry-pick lastgenre: Album stage fall back to multi-valued albumartists Jul 30, 2026
@github-actions github-actions Bot added the lastgenre lastgenre plugin label Jul 30, 2026
@JOJ0 JOJ0 mentioned this pull request Jul 30, 2026
3 tasks done
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from 58675e5 to 054d241 Compare August 2, 2026 17:36
@codecov

codecov Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.44%. Comparing base (ad758c1) to head (aa9a80a).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/lastgenre/__init__.py 72.22% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6893   +/-   ##
=======================================
  Coverage   77.44%   77.44%           
=======================================
  Files         163      163           
  Lines       21945    21957   +12     
  Branches     3386     3389    +3     
=======================================
+ Hits        16995    17005   +10     
- Misses       4128     4129    +1     
- Partials      822      823    +1     
Files with missing lines Coverage Δ
beetsplug/lastgenre/__init__.py 87.04% <72.22%> (-0.16%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from 054d241 to 08557bd Compare August 2, 2026 21:08
@JOJ0
JOJ0 marked this pull request as ready for review August 2, 2026 21:36
@JOJ0
JOJ0 requested a review from a team as a code owner August 2, 2026 21:36
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from 251def4 to e8e5265 Compare August 5, 2026 06:10
@JOJ0
JOJ0 changed the base branch from lastgenre_refactor_get_genre to lastgenre_better_existing_fallback August 5, 2026 06:49
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from e8e5265 to 95086dc Compare August 5, 2026 06:50
@JOJ0
JOJ0 changed the base branch from lastgenre_better_existing_fallback to lastgenre_improve_original_fallback August 5, 2026 06:52
@JOJ0
JOJ0 requested a lite review from Copilot August 5, 2026 06:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

PR make lastgenre album stage smarter for multi-artist albums. When Last.fm give no album tags for main albumartist, plugin now try album lookup for each value in multi-valued albumartists, then still fall through to artist stage if nothing found.

Changes:

  • Add _try_resolve_album_stage helper to hold album-stage logic and multi-valued albumartists fallback.
  • Add focused unit test that exercises per-albumartist album lookup fallback.
  • Document new multi-artist album behavior in lastgenre docs.

Reviewed changes

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

File Description
beetsplug/lastgenre/__init__.py Add album-stage helper that falls back to per-albumartists album lookups when primary album lookup empty.
test/plugins/test_lastgenre.py Add direct test for _try_resolve_album_stage fallback behavior.
docs/plugins/lastgenre.rst Document album-stage fallback to multi-valued albumartists before artist source.

Comment thread beetsplug/lastgenre/__init__.py
Comment thread test/plugins/test_lastgenre.py Outdated
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from 95086dc to e29ecb9 Compare August 12, 2026 04:18
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from e29ecb9 to 2cd9998 Compare August 17, 2026 06:37
@JOJ0
JOJ0 marked this pull request as draft August 17, 2026 06:53
JOJ0 added a commit that referenced this pull request Aug 18, 2026
## Description

The monolithic `_get_genre` method was broken down into several private
instance methods and refactored for readability. The contract is kept
and is already well tested (`test_get_genre`)

- **Core Helpers** - were moved from within `_get_genre` to a reusable
instance method and a `cached_property`:
- `_try_resolve_stage`: Handles the canonicalization and logging of
genres for a specific stage.
- `fallback`: Provides the configured fallback genre. Is used as a last
resort in `_try_resolve_existing_genres` and when `_get_genre` couldn't
find any genre in any stage at all.

- **Lookup Stages** - some were complex enough to deserve their own
instance method for readability, some stay inline in `_get_genre`:
- `_try_resolve_existing_genres`: Manages the initial check for
pre-existing genres and the `cleanup_existing` logic when `force` is
disabled.
    - track stage: stays inline
- album stage: indentical to track stage, but not worth moving /
deduplication doesn't buy much (see subsequent PR though)
- `_fetch_artist_stage`: Fetches and resolves artist-level genres,
including multi-valued album artists and "Various Artists" logic.
- `_fetch_va_genres`: specifically handles the plurality logic for
"Various Artists" albums.
- **Fallbacks**:
- `_try_resolve_original_fallback`: Handles the "keep_existing" logic
that attempts to use/canonicalize originally present genres if no new
ones are found.

Make sure to also look at subsequent PR's:

- #6890
- #6893

## To Do

- [x] ~Documentation~
- [x] Changelog. (Not required, refactor only)
- [x] ~Tests~ (_get_genre was already well covered and the signature of
the method was kept)
Base automatically changed from lastgenre_improve_original_fallback to master September 30, 2026 05:57
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch 2 times, most recently from 587af49 to aa451d8 Compare September 30, 2026 06:32
JOJ0 added a commit that referenced this pull request Sep 30, 2026
JOJ0 added 3 commits October 2, 2026 07:20
Try and concatinate genres of each member of albumartists in the
multi-valued field if no genre for the main albumartist could be found.
@JOJ0
JOJ0 force-pushed the lastgenre_album_albumartists_fallback branch from a53a8ae to dcb1066 Compare October 2, 2026 05:21
@JOJ0
JOJ0 marked this pull request as ready for review October 2, 2026 15:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lastgenre lastgenre plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lastgenre: Use multi-valued artist field for album matches too

2 participants