mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 18:12:19 +01:00
Merge pull request #512 from geigerzaehler/infer_albumartist
Infer album artist from album artist tag
This commit is contained in:
commit
cfaaecf37f
2 changed files with 20 additions and 3 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue