lastgenre: Refactor _get_genre - #6474
Conversation
|
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6474 +/- ##
==========================================
- Coverage 75.62% 75.61% -0.01%
==========================================
Files 163 163
Lines 21318 21324 +6
Branches 3361 3362 +1
==========================================
+ Hits 16122 16125 +3
- Misses 4405 4409 +4
+ Partials 791 790 -1
🚀 New features to boost your workflow:
|
806bc74 to
ba7b59a
Compare
dfef785 to
af3f67f
Compare
af3f67f to
c54f8bb
Compare
c54f8bb to
9e3e0e2
Compare
9e3e0e2 to
b4a7caf
Compare
|
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. |
There was a problem hiding this comment.
Pull request overview
grug see PR break big _get_genre into smaller helper methods, so code easier read and reason about, but keep same external behavior for lastgenre plugin.
Changes:
- move fallback + per-stage “resolve + log” logic into private instance helpers
- pull out “existing genres / cleanup_existing” handling and “original fallback” handling into dedicated helpers
- pull out artist-stage fetching (incl. VA plurality) into helper, so
_get_genremain flow more straight
|
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. |
Description
The monolithic
_get_genremethod 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_genreto reusable instance methods:_try_resolve_stage: Handles the canonicalization and logging of genres for a specific stage._configured_fallback: Provides the configured fallback genre.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 thecleanup_existinglogic._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:
To Do
DocumentationTests(_get_genre was already well covered and the signature of the method was kept)