From 9e63915f65017408d6f12b22f7ba96bbb866cf5e Mon Sep 17 00:00:00 2001 From: JoeLametta Date: Wed, 29 Jan 2020 13:33:11 +0000 Subject: [PATCH] Display release country in matching releases This simplifies choosing the correct release when there are multiple matches. If a certain release has multiple countries associated, all will be shown. Thanks to the user "the-confessor" for testing this new feature. Fixes #451. Signed-off-by: JoeLametta --- whipper/common/mbngs.py | 10 ++++++++++ whipper/common/program.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/whipper/common/mbngs.py b/whipper/common/mbngs.py index 3c925f9..ca9f1bf 100644 --- a/whipper/common/mbngs.py +++ b/whipper/common/mbngs.py @@ -69,6 +69,8 @@ class DiscMetadata: :param title: title of the disc (with disambiguation) :param releaseTitle: title of the release (without disambiguation) :type tracks: list of :any:`TrackMetadata` + :param countries: MusicBrainz release countries + :type countries: list or None """ artist = None sortName = None @@ -87,6 +89,7 @@ class DiscMetadata: catalogNumber = None barcode = None + countries = None def __init__(self): self.tracks = [] @@ -262,6 +265,13 @@ def _getMetadata(release, discid=None, country=None): discMD.url = 'https://musicbrainz.org/release/' + release['id'] discMD.barcode = release.get('barcode', None) + mb_rel = release.get('release-event-list', None) + # NOTE: check included as I don't know if this one is always available + if mb_rel is not None: + countries = [rel.get('area', {}).get('name', None) for rel in mb_rel] + discMD.countries = list(filter(None, countries)) + else: + discMD.countries = list(filter(None, [release.get('country', None)])) lil = release.get('label-info-list', [{}]) if lil: discMD.catalogNumber = lil[0].get('catalog-number') diff --git a/whipper/common/program.py b/whipper/common/program.py index 9c8a0cd..7337693 100644 --- a/whipper/common/program.py +++ b/whipper/common/program.py @@ -318,6 +318,8 @@ class Program: print('Type : %s' % metadata.releaseType) if metadata.barcode: print("Barcode : %s" % metadata.barcode) + if metadata.countries: + print("Country : %s" % ', '.join(metadata.countries)) # TODO: Add test for non ASCII catalog numbers: see issue #215 if metadata.catalogNumber: print("Cat no : %s" % metadata.catalogNumber)