Skip to content

Commit

Permalink
mbsync: fix updating album with invalid first track MBID
Browse files Browse the repository at this point in the history
MBID of recording could become invalid after merging. The existing
code always copies metadata from first track after updating. But for
albums with invalid track MBID that happens to be the first track,
MusicBrainz changes won't be applied to whole album, only whose
tracks with valid MBID. This is particularly annoying since those
changes are actually displayed for every `beet mbsync` run, but never
get applied.

Fix this issue by finding any track that get MusicBrainz updates, and
apply it to whole album.
  • Loading branch information
bjin committed May 10, 2018
1 parent 7e0fbef commit 69d6dfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion beetsplug/mbsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ def albums(self, lib, query, move, pretend, write):
with lib.transaction():
autotag.apply_metadata(album_info, mapping)
changed = False
# Find any changed item to apply MusicBrainz changes to album.
any_changed_item = items[0]
for item in items:
item_changed = ui.show_model_changes(item)
changed |= item_changed
if item_changed:
any_changed_item = item
apply_item_changes(lib, item, move, pretend, write)

if not changed:
Expand All @@ -165,7 +168,7 @@ def albums(self, lib, query, move, pretend, write):
if not pretend:
# Update album structure to reflect an item in it.
for key in library.Album.item_keys:
a[key] = items[0][key]
a[key] = any_changed_item[key]
a.store()

# Move album art (and any inconsistent items).
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Fixes:
tracks. :bug:`2537`
* In the ``mbsync`` plugin, support MusicBrainz recording ID changes, relying
on release track IDs instead. Thanks to :user:`jdetrey`. :bug:`1234`
* In the ``mbsync`` plugin, allow beets to update album if the first track
has a missing MusicBrainz recording ID.


For developers:
Expand Down

0 comments on commit 69d6dfe

Please sign in to comment.