Skip to content

Commit

Permalink
Display release country in matching releases
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
JoeLametta committed Feb 4, 2020
1 parent 3213241 commit 9e63915
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions whipper/common/mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -87,6 +89,7 @@ class DiscMetadata:

catalogNumber = None
barcode = None
countries = None

def __init__(self):
self.tracks = []
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ def getMusicBrainz(self, ittoc, mbdiscid, release=None, country=None,
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)
Expand Down

0 comments on commit 9e63915

Please sign in to comment.