Split release and release-group disambiguation into separate fields.

This commit is contained in:
David Logie 2018-09-05 12:45:19 +01:00
parent 45772bb80b
commit 57b268923f
10 changed files with 57 additions and 47 deletions

View file

@ -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:

View file

@ -66,6 +66,7 @@ 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 +79,9 @@ class AlbumInfo(object):
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 +104,7 @@ class AlbumInfo(object):
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 +121,8 @@ class AlbumInfo(object):
"""
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'))

View file

@ -346,13 +346,11 @@ 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 = []
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.

View file

@ -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: '[]'

View file

@ -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',

View file

@ -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:

View file

@ -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.

View file

@ -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

View file

@ -583,7 +583,7 @@ ALBUM_INFO_FIELDS = ['album', 'album_id', 'artist', 'artist_id',
'asin', 'albumtype', 'va', 'label',
'artist_sort', 'releasegroup_id', 'catalognum',
'language', 'country', 'albumstatus', 'media',
'albumdisambig', 'artist_credit',
'albumdisambig', 'releasegroupdisambig', 'artist_credit',
'data_source', 'data_url']

View file

@ -302,8 +302,8 @@ class MBAlbumInfoTest(_common.TestCase):
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),