diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index c4ee1300e3..90d294c615 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -152,6 +152,7 @@ def apply_metadata(album_info, mapping): 'country', 'albumstatus', 'albumdisambig', + 'releasegroupdisambig', 'data_source',): value = getattr(album_info, field) if value is not None: diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 1c62a54c5c..d15cba2696 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -66,6 +66,8 @@ class AlbumInfo(object): - ``albumstatus``: MusicBrainz release status (Official, etc.) - ``media``: delivery mechanism (Vinyl, etc.) - ``albumdisambig``: MusicBrainz release disambiguation comment + - ``releasegroupdisambig``: MusicBrainz release group + disambiguation comment. - ``artist_credit``: Release-specific artist name - ``data_source``: The original data source (MusicBrainz, Discogs, etc.) - ``data_url``: The data source release URL. @@ -78,9 +80,9 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, label=None, mediums=None, artist_sort=None, releasegroup_id=None, catalognum=None, script=None, language=None, country=None, albumstatus=None, media=None, - albumdisambig=None, artist_credit=None, original_year=None, - original_month=None, original_day=None, data_source=None, - data_url=None): + albumdisambig=None, releasegroupdisambig=None, + artist_credit=None, original_year=None, original_month=None, + original_day=None, data_source=None, data_url=None): self.album = album self.album_id = album_id self.artist = artist @@ -103,6 +105,7 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, self.albumstatus = albumstatus self.media = media self.albumdisambig = albumdisambig + self.releasegroupdisambig = releasegroupdisambig self.artist_credit = artist_credit self.original_year = original_year self.original_month = original_month @@ -119,7 +122,8 @@ def decode(self, codec='utf-8'): """ for fld in ['album', 'artist', 'albumtype', 'label', 'artist_sort', 'catalognum', 'script', 'language', 'country', - 'albumstatus', 'albumdisambig', 'artist_credit', 'media']: + 'albumstatus', 'albumdisambig', 'releasegroupdisambig', + 'artist_credit', 'media']: value = getattr(self, fld) if isinstance(value, bytes): setattr(self, fld, value.decode(codec, 'ignore')) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 50d28a538a..4ea56af7ff 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -346,13 +346,12 @@ def album_info(release): info.releasegroup_id = release['release-group']['id'] info.albumstatus = release.get('status') - # Build up the disambiguation string from the release group and release. - disambig = [] + # Get the disambiguation strings at the release and release group level. if release['release-group'].get('disambiguation'): - disambig.append(release['release-group'].get('disambiguation')) + info.releasegroupdisambig = \ + release['release-group'].get('disambiguation') if release.get('disambiguation'): - disambig.append(release.get('disambiguation')) - info.albumdisambig = u', '.join(disambig) + info.albumdisambig = release.get('disambiguation') # Get the "classic" Release type. This data comes from a legacy API # feature before MusicBrainz supported multiple release types. diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 17e07edec8..96de08b900 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -50,7 +50,7 @@ max_filename_length: 0 aunique: keys: albumartist album - disambiguators: albumtype year label catalognum albumdisambig + disambiguators: albumtype year label catalognum albumdisambig releasegroupdisambig bracket: '[]' diff --git a/beets/library.py b/beets/library.py index be67065a0b..d0571ed3a3 100644 --- a/beets/library.py +++ b/beets/library.py @@ -469,6 +469,7 @@ class Item(LibModel): 'albumstatus': types.STRING, 'media': types.STRING, 'albumdisambig': types.STRING, + 'releasegroupdisambig': types.STRING, 'disctitle': types.STRING, 'encoder': types.STRING, 'rg_track_gain': types.NULL_FLOAT, @@ -903,34 +904,35 @@ class Album(LibModel): 'artpath': PathType(True), 'added': DateType(), - 'albumartist': types.STRING, - 'albumartist_sort': types.STRING, - 'albumartist_credit': types.STRING, - 'album': types.STRING, - 'genre': types.STRING, - 'year': types.PaddedInt(4), - 'month': types.PaddedInt(2), - 'day': types.PaddedInt(2), - 'disctotal': types.PaddedInt(2), - 'comp': types.BOOLEAN, - 'mb_albumid': types.STRING, - 'mb_albumartistid': types.STRING, - 'albumtype': types.STRING, - 'label': types.STRING, - 'mb_releasegroupid': types.STRING, - 'asin': types.STRING, - 'catalognum': types.STRING, - 'script': types.STRING, - 'language': types.STRING, - 'country': types.STRING, - 'albumstatus': types.STRING, - 'albumdisambig': types.STRING, - 'rg_album_gain': types.NULL_FLOAT, - 'rg_album_peak': types.NULL_FLOAT, - 'r128_album_gain': types.PaddedInt(6), - 'original_year': types.PaddedInt(4), - 'original_month': types.PaddedInt(2), - 'original_day': types.PaddedInt(2), + 'albumartist': types.STRING, + 'albumartist_sort': types.STRING, + 'albumartist_credit': types.STRING, + 'album': types.STRING, + 'genre': types.STRING, + 'year': types.PaddedInt(4), + 'month': types.PaddedInt(2), + 'day': types.PaddedInt(2), + 'disctotal': types.PaddedInt(2), + 'comp': types.BOOLEAN, + 'mb_albumid': types.STRING, + 'mb_albumartistid': types.STRING, + 'albumtype': types.STRING, + 'label': types.STRING, + 'mb_releasegroupid': types.STRING, + 'asin': types.STRING, + 'catalognum': types.STRING, + 'script': types.STRING, + 'language': types.STRING, + 'country': types.STRING, + 'albumstatus': types.STRING, + 'albumdisambig': types.STRING, + 'releasegroupdisambig': types.STRING, + 'rg_album_gain': types.NULL_FLOAT, + 'rg_album_peak': types.NULL_FLOAT, + 'r128_album_gain': types.PaddedInt(6), + 'original_year': types.PaddedInt(4), + 'original_month': types.PaddedInt(2), + 'original_day': types.PaddedInt(2), } _search_fields = ('album', 'albumartist', 'genre') @@ -969,6 +971,7 @@ class Album(LibModel): 'country', 'albumstatus', 'albumdisambig', + 'releasegroupdisambig', 'rg_album_gain', 'rg_album_peak', 'r128_album_gain', diff --git a/docs/changelog.rst b/docs/changelog.rst index 9b8ed5770a..95c774ab3d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -39,6 +39,9 @@ New features: :bug:`3017` * A new ``aunique`` configuration option allows setting default options for the :ref:`aunique` template function. +* The ``albumdisambig`` field no longer includes the MusicBrainz release group + disambiguation comment. A new ``releasegroupdisambig`` field has been added. + :bug:`3024` Fixes: diff --git a/docs/reference/config.rst b/docs/reference/config.rst index b0ce63d52a..ed8d767f53 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -298,7 +298,7 @@ The defaults look like this:: aunique: keys: albumartist album - disambiguators: albumtype year label catalognum albumdisambig + disambiguators: albumtype year label catalognum albumdisambig releasegroupdisambig bracket: '[]' See :ref:`aunique` for more details. diff --git a/docs/reference/pathformat.rst b/docs/reference/pathformat.rst index 5f8c0b2010..79998a9e1d 100644 --- a/docs/reference/pathformat.rst +++ b/docs/reference/pathformat.rst @@ -125,11 +125,13 @@ looking for one that distinguishes each of the duplicate albums from each other. The first such field is used as the result for ``%aunique``. If no field suffices, an arbitrary number is used to distinguish the two albums. -The default identifiers are ``albumartist album`` and the default disambiguators -are ``albumtype year label catalognum albumdisambig``. So you can get reasonable -disambiguation behavior if you just use ``%aunique{}`` with no parameters in -your path forms (as in the default path formats), but you can customize the -disambiguation if, for example, you include the year by default in path formats. +The default identifiers are ``albumartist album`` and the default +disambiguators are ``albumtype year label catalognum albumdisambig +releasegroupdisambig``. So you can get reasonable disambiguation +behavior if you just use ``%aunique{}`` with no parameters in your +path forms (as in the default path formats), but you can customize the +disambiguation if, for example, you include the year by default in +path formats. The default characters used as brackets are ``[]``. To change this, provide a third argument to the ``%aunique`` function consisting of two characters: the left diff --git a/test/helper.py b/test/helper.py index 21346312cb..92128f5111 100644 --- a/test/helper.py +++ b/test/helper.py @@ -583,7 +583,7 @@ def generate_album_info(album_id, track_values): 'asin', 'albumtype', 'va', 'label', 'artist_sort', 'releasegroup_id', 'catalognum', 'language', 'country', 'albumstatus', 'media', - 'albumdisambig', 'artist_credit', + 'albumdisambig', 'releasegroupdisambig', 'artist_credit', 'data_source', 'data_url'] diff --git a/test/test_mb.py b/test/test_mb.py index a6d31ef7b2..8dd9667920 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -302,8 +302,8 @@ def test_parse_media(self): def test_parse_disambig(self): release = self._make_release(None) d = mb.album_info(release) - self.assertEqual(d.albumdisambig, - 'RG_DISAMBIGUATION, R_DISAMBIGUATION') + self.assertEqual(d.albumdisambig, 'R_DISAMBIGUATION') + self.assertEqual(d.releasegroupdisambig, 'RG_DISAMBIGUATION') def test_parse_disctitle(self): tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0),