Simplify tagging
Refactor item tagging and fix several underlying issues.
Fixes
- Synchronise all artist list fields. Notably,
artist_sort/artists_sortandartist_credit/artists_creditfields have not been synchronised. - Fix
overwrite_nullconfiguration which was previously ignored for fields defined inautotag/__init__.py::SPECIAL_FIELDS.
Updates
- Move metadata application logic into
Matchobjects: addMatch.apply_metadata,AlbumMatch.apply_metadata,AlbumMatch.apply_album_metadata, andTrackMatch.apply_metadata; callers now use those methods instead of legacy free functions. - Remove legacy functions from
beets.autotag.__init__(apply_item_metadata,apply_album_metadata,apply_metadata) and related globals (SPECIAL_FIELDS,log), and export only core types (AlbumInfo,AlbumMatch,TrackInfo,TrackMatch,Proposal,Recommendation,tag_album,tag_item). - Add structured metadata facilities to
Infoand subclasses:Info.typeclass property andnullable_fieldsfor per-type 'overwrite_null' config.Info.raw_dataandInfo.item_datacomputed properties to applyartist_creditrules, filter nulls, and map media-specific field names.AlbumInfoandTrackInfoextendraw_data/item_databehavior to handle album/track specifics (date zeroing,tracktotal,mb_releasetrackid, per-disc numbering).
- Introduce
TrackInfo.merge_with_albumto merge track-level data with album-level fallback for a final item payload. - Move
correct_list_fieldstohooks.pyand update it to keep unmapped / non-media single/list fields in sync (artist<->artists,albumtype<->albumtypes, etc.). - Wire changes through the codebase:
- Pass
Itemobjects intoTrackMatchinmatch.tag_itemto enable item-level metadata application. - Replace calls to removed
autotagapply functions withMatch.apply_metadatainvocations inbeets/importer/tasks.py,beetsplug/bpsync.py, andbeetsplug/mbsync.py. - Update importer logic to set album artist fallbacks for
albumartists/mb_albumartistidswhen missing.
- Pass
- Add and update tests:
- New
test/autotag/test_hooks.pyandtest/autotag/test_match.pyto validate new data mapping, list field synchronization, overwrite behavior, and assignment logic.
- New
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
:x: Patch coverage is 95.45455% with 5 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 68.26%. Comparing base (60b4a38) to head (cf31d00).
:warning: Report is 1 commits behind head on master.
:white_check_mark: All tests successful. No failed tests found.
Additional details and impacted files
@@ Coverage Diff @@
## master #6165 +/- ##
=======================================
Coverage 68.26% 68.26%
=======================================
Files 138 138
Lines 18791 18766 -25
Branches 3167 3158 -9
=======================================
- Hits 12827 12811 -16
+ Misses 5290 5286 -4
+ Partials 674 669 -5
| Files with missing lines | Coverage Δ | |
|---|---|---|
| beets/autotag/__init__.py | 72.72% <ø> (-14.89%) |
:arrow_down: |
| beets/autotag/match.py | 76.92% <100.00%> (ø) |
|
| beetsplug/mbsync.py | 82.05% <100.00%> (+0.23%) |
:arrow_up: |
| beets/importer/tasks.py | 90.83% <92.30%> (-0.06%) |
:arrow_down: |
| beets/autotag/hooks.py | 98.97% <97.70%> (-1.03%) |
:arrow_down: |
| beetsplug/bpsync.py | 19.04% <50.00%> (+0.97%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@semohr @henry-oberholtzer @JOJ0 would be happy to have your eyes over this as I think this is a significant piece of work making autotagging somewhat simpler (hopefully!).
@semohr @henry-oberholtzer @JOJ0 would be happy to have your eyes over this as I think this is a significant piece of work making autotagging somewhat simpler (hopefully!).
I'll try to find some time after first wave of xmadness is over