Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split release and release-group disambiguation into separate fields. #3025

Merged
merged 2 commits into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beets/autotag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'))
Expand Down
9 changes: 4 additions & 5 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe preserving a version of this comment would be useful; for example:

Get the disambiguation strings at the release and release group level.

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.
Expand Down
2 changes: 1 addition & 1 deletion beets/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[]'


Expand Down
59 changes: 31 additions & 28 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -969,6 +971,7 @@ class Album(LibModel):
'country',
'albumstatus',
'albumdisambig',
'releasegroupdisambig',
'rg_album_gain',
'rg_album_peak',
'r128_album_gain',
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 7 additions & 5 deletions docs/reference/pathformat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']


Expand Down
4 changes: 2 additions & 2 deletions test/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down