File tree Expand file tree Collapse file tree 3 files changed +24
-27
lines changed
Expand file tree Collapse file tree 3 files changed +24
-27
lines changed Original file line number Diff line number Diff line change @@ -313,21 +313,20 @@ def apply_metadata(
313313
314314 # MusicBrainz IDs.
315315 item .mb_trackid = track_info .track_id
316- item .mb_releasetrackid = track_info .release_track_id
317- item .mb_albumid = album_info .album_id
318- if track_info .artist_id :
319- item .mb_artistid = track_info .artist_id
320- else :
321- item .mb_artistid = album_info .artist_id
316+ item .mb_releasetrackid = track_info .release_track_id or item .mb_trackid
322317
323- if track_info .artists_ids :
324- item .mb_artistids = track_info .artists_ids
325- else :
326- item .mb_artistids = album_info .artists_ids
318+ item .mb_albumid = album_info .album_id
319+ item .mb_releasegroupid = album_info .releasegroup_id
327320
328321 item .mb_albumartistid = album_info .artist_id
329- item .mb_albumartistids = album_info .artists_ids
330- item .mb_releasegroupid = album_info .releasegroup_id
322+ item .mb_albumartistids = album_info .artists_ids or (
323+ [ai ] if (ai := item .mb_albumartistid ) else []
324+ )
325+
326+ item .mb_artistid = track_info .artist_id or item .mb_albumartistid
327+ item .mb_artistids = track_info .artists_ids or (
328+ [iai ] if (iai := item .mb_artistid ) else []
329+ )
331330
332331 # Compilation flag.
333332 item .comp = album_info .va
Original file line number Diff line number Diff line change @@ -428,14 +428,17 @@ def align_album_level_fields(self):
428428 elif self .choice_flag in (Action .APPLY , Action .RETAG ):
429429 # Applying autotagged metadata. Just get AA from the first
430430 # item.
431- if not self .items [0 ].albumartist :
432- changes ["albumartist" ] = self .items [0 ].artist
433- if not self .items [0 ].albumartists :
434- changes ["albumartists" ] = self .items [0 ].artists
435- if not self .items [0 ].mb_albumartistid :
436- changes ["mb_albumartistid" ] = self .items [0 ].mb_artistid
437- if not self .items [0 ].mb_albumartistids :
438- changes ["mb_albumartistids" ] = self .items [0 ].mb_artistids
431+ first = self .items [0 ]
432+ if not first .albumartist :
433+ changes ["albumartist" ] = first .artist
434+ if not first .albumartists :
435+ changes ["albumartists" ] = first .artists or [first .artist ]
436+ if not first .mb_albumartistid :
437+ changes ["mb_albumartistid" ] = first .mb_artistid
438+ if not first .mb_albumartistids :
439+ changes ["mb_albumartistids" ] = first .mb_artistids or [
440+ first .mb_artistid
441+ ]
439442
440443 # Apply new metadata.
441444 for item in self .items :
Original file line number Diff line number Diff line change @@ -319,13 +319,8 @@ def test_edit_apply_asis(self):
319319 self .assertItemFieldsModified (
320320 self .lib .items (),
321321 self .items_orig ,
322- ["title" ],
323- self .IGNORED
324- + [
325- "albumartist" ,
326- "mb_albumartistid" ,
327- "mb_albumartistids" ,
328- ],
322+ ["title" , "albumartist" , "albumartists" ],
323+ self .IGNORED + ["mb_albumartistid" , "mb_albumartistids" ],
329324 )
330325 assert all ("Edited Track" in i .title for i in self .lib .items ())
331326
You can’t perform that action at this time.
0 commit comments