beets icon indicating copy to clipboard operation
beets copied to clipboard

Album tagging for Musicbrainz single import

Open jjmeist opened this issue 1 month ago • 3 comments

Fixes #5886

This PR resolves an issue where standalone tracks imported via item_candidates() were missing album information even when the MusicBrainz API response included a release-list.

Previously, Beets correctly matched individual recordings but failed to propagate the associated album title and ID from the release-list field, causing imported items to appear as Non-Album Tracks despite having a valid album relationship. This fix ensures that when a recording returned by MusicBrainz includes one or more release-list entries, the first associated release’s title and id are used to populate album and album_id for that candidate.

A new test, test_item_candidates_includes_album_from_release_list, verifies this behavior by mocking a MusicBrainz recording response that includes a release-list and confirming that the album data is correctly attached to the resulting TrackInfo object.

[ ]Documentation (N/A — behavior fix, no user-facing config changes). [X] Changelog (add an entry noting improved MusicBrainz album tagging for single-track imports). [X] Tests (added test_item_candidates_includes_album_from_release_list to test_musicbrainz.py).

jjmeist avatar Nov 12 '25 17:11 jjmeist

Codecov Report

:x: Patch coverage is 66.66667% with 7 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 67.94%. Comparing base (2bd77b9) to head (7a85017). :white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/musicbrainz.py 66.66% 3 Missing and 4 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6160      +/-   ##
==========================================
+ Coverage   67.93%   67.94%   +0.01%     
==========================================
  Files         137      137              
  Lines       18677    18697      +20     
  Branches     3155     3161       +6     
==========================================
+ Hits        12688    12704      +16     
+ Misses       5324     5323       -1     
- Partials      665      670       +5     
Files with missing lines Coverage Δ
beetsplug/musicbrainz.py 79.20% <66.66%> (+0.04%) :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.

codecov[bot] avatar Nov 12 '25 17:11 codecov[bot]

Thanks for the submission. And yeah we have this eg for discogs and spotify, but there it's easier since eg one discogs track is on one album, there is no such thing as multiple albums for one recording (aka track). discogs searches for single tracks look up albums anyway.

up to now for musicbrainz singletons, keeping them non-album tracks was a design choice.

so what's interesting here is that we assume simply the first release in the list is the right one. it's better than nothing but is there a pattern? how can we know the first is the best idea?

maybe some examples? there is no such thing as asking mb for a master release? or first ever released? what is the order of the releases in that list?

JOJ0 avatar Nov 29 '25 22:11 JOJ0

maybe add some notes where -s is described around here: https://beets.readthedocs.io/en/latest/reference/cli.html#id2

JOJ0 avatar Dec 09 '25 16:12 JOJ0