Add artist_credit config option

This commit is contained in:
Denis Defreyne 2018-04-07 22:20:48 +02:00
parent a829fa348f
commit 0202d762bf
No known key found for this signature in database
GPG key ID: 937343BCE2D2680B
5 changed files with 47 additions and 8 deletions

View file

@ -63,12 +63,19 @@ def apply_metadata(album_info, mapping):
mapping from Items to TrackInfo objects.
"""
for item, track_info in mapping.items():
# Album, artist, track count.
if track_info.artist:
item.artist = track_info.artist
# Artist or artist credit.
if config['artist_credit']:
item.artist = (track_info.artist_credit or
track_info.artist or
album_info.artist_credit or
album_info.artist)
item.albumartist = (album_info.artist_credit or
album_info.artist)
else:
item.artist = album_info.artist
item.albumartist = album_info.artist
item.artist = (track_info.artist or album_info.artist)
item.albumartist = album_info.artist
# Album.
item.album = album_info.album
# Artist sort and credit names.

View file

@ -56,6 +56,7 @@ per_disc_numbering: no
verbose: 0
terminal_encoding:
original_date: no
artist_credit: no
id3v23: no
va_name: "Various Artists"

View file

@ -18,6 +18,9 @@ New features:
* :doc:`/plugins/web`: added the boolean ``cors_supports_credentials`` option to
allow in-browser clients to login to the beet web server even when it is
protected by an authorization mechanism.
* A new importer configuration ``artist_credit`` will tell beets to prefer the
artist credit over the artist when autotagging.
:bug:`1249`
Fixes:
@ -75,9 +78,9 @@ Fixes:
album art would not work and throw an exception. It now works as expected.
Additionally, the server will now return a 404 response when the album id
is unknown, instead of a 500 response and a thrown exception. :bug:`2823`
* :doc:`/plugins/web`: In a python 3 enviroment, the server would throw an
* :doc:`/plugins/web`: In a python 3 enviroment, the server would throw an
exception if non latin-1 characters where in the File name.
It now checks if non latin-1 characters are in the filename and changes
It now checks if non latin-1 characters are in the filename and changes
them to ascii-characters in that case :bug:`2815`
* Partially fix bash completion for subcommand names that contain hyphens.
:bug:`2836` :bug:`2837`

View file

@ -253,6 +253,15 @@ Either ``yes`` or ``no``, indicating whether matched albums should have their
That is, if this option is turned on, then ``year`` will always equal
``original_year`` and so on. Default: ``no``.
.. _artist_credit:
artist_credit
~~~~~~~~~~~~~
Either ``yes`` or ``no``, indicating whether matched tracks and albums should
use the artist credit, rather than the artist. That is, if this option is turned
on, then ``artist`` will contain the artist as credited on the release.
.. _per_disc_numbering:
per_disc_numbering

View file

@ -616,12 +616,13 @@ class AssignmentTest(unittest.TestCase):
class ApplyTestUtil(object):
def _apply(self, info=None, per_disc_numbering=False):
def _apply(self, info=None, per_disc_numbering=False, artist_credit=False):
info = info or self.info
mapping = {}
for i, t in zip(self.items, info.tracks):
mapping[i] = t
config['per_disc_numbering'] = per_disc_numbering
config['artist_credit'] = artist_credit
autotag.apply_metadata(info, mapping)
@ -706,6 +707,24 @@ class ApplyTest(_common.TestCase, ApplyTestUtil):
self.assertEqual(self.items[0].tracktotal, 1)
self.assertEqual(self.items[1].tracktotal, 1)
def test_artist_credit(self):
self._apply(artist_credit=True)
self.assertEqual(self.items[0].artist, 'trackArtistCredit')
self.assertEqual(self.items[1].artist, 'albumArtistCredit')
self.assertEqual(self.items[0].albumartist, 'albumArtistCredit')
self.assertEqual(self.items[1].albumartist, 'albumArtistCredit')
def test_artist_credit_prefers_artist_over_albumartist_credit(self):
self.info.tracks[0].artist = 'oldArtist'
self.info.tracks[0].artist_credit = None
self._apply(artist_credit=True)
self.assertEqual(self.items[0].artist, 'oldArtist')
def test_artist_credit_falls_back_to_albumartist(self):
self.info.artist_credit = None
self._apply(artist_credit=True)
self.assertEqual(self.items[1].artist, 'artistNew')
def test_mb_trackid_applied(self):
self._apply()
self.assertEqual(self.items[0].mb_trackid,