Add AlbumInfo.data_url property, populate it for Discogs matches and display it when it is non-empty.

Makes it easier for people to find the best Discogs (or other) match
and import it to Music Brainz using a grease monkey or similar script.
This commit is contained in:
Tai Lee 2013-05-24 22:50:14 +10:00
parent 1ad5d9eee1
commit 7f068a8c03
3 changed files with 11 additions and 2 deletions

View file

@ -52,6 +52,7 @@ class AlbumInfo(object):
- ``albumdisambig``: MusicBrainz release disambiguation comment
- ``artist_credit``: Release-specific artist name
- ``data_source``: The original data source (MusicBrainz, Discogs, etc.)
- ``data_url``: The data source release URL.
The fields up through ``tracks`` are required. The others are
optional and may be None.
@ -62,7 +63,8 @@ class AlbumInfo(object):
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):
original_month=None, original_day=None, data_source=None,
data_url=None):
self.album = album
self.album_id = album_id
self.artist = artist
@ -90,6 +92,7 @@ class AlbumInfo(object):
self.original_month = original_month
self.original_day = original_day
self.data_source = data_source or 'Unknown'
self.data_url = data_url
# Work around a bug in python-musicbrainz-ngs that causes some
# strings to be bytes rather than Unicode.

View file

@ -216,6 +216,10 @@ def show_change(cur_artist, cur_album, match):
message += u' %s' % ui.colorize('yellow', PARTIAL_MATCH_MESSAGE)
print_(message)
# Data URL.
if match.info.data_url:
print_('URL:\n %s' % match.info.data_url)
# Info line.
info = []
info.append('(Similarity: %s)' % dist_string(match.distance))

View file

@ -91,6 +91,7 @@ class DiscogsPlugin(BeetsPlugin):
catalogno = None
country = result.data.get('country')
media = result.data['formats'][0]['name']
data_url = result.data['uri']
return AlbumInfo(album, album_id, artist, artist_id, tracks, asin=None,
albumtype=albumtype, va=va, year=year, month=None,
day=None, label=label, mediums=mediums,
@ -99,7 +100,8 @@ class DiscogsPlugin(BeetsPlugin):
country=country, albumstatus=None, media=media,
albumdisambig=None, artist_credit=None,
original_year=None, original_month=None,
original_day=None, data_source='Discogs')
original_day=None, data_source='Discogs',
data_url=data_url)
def get_artist(self, artists):
"""Returns an artist string (all artists) and an artist_id (the main