diff --git a/beets/importer.py b/beets/importer.py index 1a16c54be..1fa2684c7 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -107,11 +107,12 @@ def _infer_album_fields(task): if task.choice_flag == action.ASIS: # Taking metadata "as-is". Guess whether this album is VA. - plur_artist, freq = util.plurality([i.artist for i in task.items]) + plur_albumartist, freq = util.plurality( + [i.albumartist or i.artist for i in task.items]) if freq == len(task.items) or (freq > 1 and float(freq) / len(task.items) >= SINGLE_ARTIST_THRESH): # Single-artist album. - changes['albumartist'] = plur_artist + changes['albumartist'] = plur_albumartist changes['comp'] = False else: # VA. diff --git a/test/test_importer.py b/test/test_importer.py index 6339c32ff..86e7c521e 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -72,6 +72,7 @@ class NonAutotaggedImportTest(_common.TestCase): 'track': (i+1), 'artist': 'The Artist', 'album': 'The Album', + 'albumartist': 'The Album Artist', 'title': title, })) @@ -93,7 +94,7 @@ class NonAutotaggedImportTest(_common.TestCase): self._run_import() albums = self.lib.albums() self.assertEqual(len(albums), 1) - self.assertEqual(albums[0].albumartist, 'The Artist') + self.assertEqual(albums[0].albumartist, 'The Album Artist') def _copy_arrives(self): artist_folder = os.path.join(self.libdir, 'The Artist') @@ -606,6 +607,21 @@ class InferAlbumDataTest(_common.TestCase): self.assertFalse(self.items[0].comp) self.assertEqual(self.items[0].albumartist, self.items[2].artist) + def test_asis_track_albumartist_override(self): + self.items[0].artist = 'another artist' + self.items[1].artist = 'some other artist' + for item in self.items: + item.albumartist = 'some album artist' + item.mb_albumartistid = 'some album artist id' + self.task.set_choice(importer.action.ASIS) + + self._infer() + + self.assertEqual(self.items[0].albumartist, + 'some album artist') + self.assertEqual(self.items[0].mb_albumartistid, + 'some album artist id') + def test_apply_gets_artist_and_id(self): self.task.set_choice(AlbumMatch(0, None, {}, set(), set())) # APPLY