From 50a89e790c9dbc10a8733de486fa17183618f295 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 2 Feb 2013 12:42:53 -0800 Subject: [PATCH] both release and release group disambig (#87) This joins the two strings with a comma if both are present. --- beets/autotag/mb.py | 9 ++++++++- docs/changelog.rst | 2 ++ test/test_mb.py | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index f3fc6bcb4..509ce4ac5 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -188,10 +188,17 @@ def album_info(release): info.va = info.artist_id == VARIOUS_ARTISTS_ID info.asin = release.get('asin') info.releasegroup_id = release['release-group']['id'] - info.albumdisambig = release['release-group'].get('disambiguation') info.country = release.get('country') 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')) + if release.get('disambiguation'): + disambig.append(release.get('disambiguation')) + info.albumdisambig = u', '.join(disambig) + # Release type not always populated. if 'type' in release['release-group']: reltype = release['release-group']['type'] diff --git a/docs/changelog.rst b/docs/changelog.rst index 82c7f5f08..064b59daa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -32,6 +32,8 @@ Other new stuff: * Album listings in the importer UI now show the release medium (CD, Vinyl, 3xCD, etc.) as well as the disambiguation string. Thanks to Peter Schnebel. +* When getting data from MusicBrainz, the album disambiguation string + (``albumdisambig``) now reflects both the release and the release group. * :doc:`/plugins/mpdupdate`: Sends an update message whenever *anything* in the database changes---not just when importing. Thanks to Dang Mai Hai. * When the importer UI shows a difference in track numbers or durations, they diff --git a/test/test_mb.py b/test/test_mb.py index 7e007e1e4..9a94ee348 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -23,12 +23,12 @@ class MBAlbumInfoTest(unittest.TestCase): 'title': 'ALBUM TITLE', 'id': 'ALBUM ID', 'asin': 'ALBUM ASIN', - 'disambiguation': 'DISAMBIGUATION', + 'disambiguation': 'R_DISAMBIGUATION', 'release-group': { 'type': 'Album', 'first-release-date': date_str, 'id': 'RELEASE GROUP ID', - 'disambiguation': 'DISAMBIGUATION', + 'disambiguation': 'RG_DISAMBIGUATION', }, 'artist-credit': [ { @@ -248,7 +248,8 @@ class MBAlbumInfoTest(unittest.TestCase): def test_parse_disambig(self): release = self._make_release(None) d = mb.album_info(release) - self.assertEqual(d.albumdisambig, 'DISAMBIGUATION') + self.assertEqual(d.albumdisambig, + 'RG_DISAMBIGUATION, R_DISAMBIGUATION') def test_parse_disctitle(self): tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0),