adding genre, released_date and discogs_release_id

This commit is contained in:
Peter 2019-06-16 21:55:35 +02:00
parent 34c28529a0
commit 90cf579ee3
5 changed files with 31 additions and 11 deletions

View file

@ -156,6 +156,9 @@ def apply_metadata(album_info, mapping):
'language',
'country',
'style',
'genre',
'discogs_release_id',
'released_date',
'albumstatus',
'albumdisambig',
'releasegroupdisambig',

View file

@ -79,10 +79,10 @@ class AlbumInfo(object):
albumtype=None, va=False, year=None, month=None, day=None,
label=None, mediums=None, artist_sort=None,
releasegroup_id=None, catalognum=None, script=None,
language=None, country=None, style=None, albumstatus=None,
language=None, country=None, style=None, genre=None, albumstatus=None,
media=None, albumdisambig=None, releasegroupdisambig=None,
artist_credit=None, original_year=None, original_month=None,
original_day=None, data_source=None, data_url=None):
original_day=None, data_source=None, data_url=None, discogs_release_id=None, released_date=None):
self.album = album
self.album_id = album_id
self.artist = artist
@ -103,6 +103,7 @@ class AlbumInfo(object):
self.language = language
self.country = country
self.style = style
self.genre = genre
self.albumstatus = albumstatus
self.media = media
self.albumdisambig = albumdisambig
@ -113,6 +114,8 @@ class AlbumInfo(object):
self.original_day = original_day
self.data_source = data_source
self.data_url = data_url
self.discogs_release_id = discogs_release_id
self.released_date = released_date
# Work around a bug in python-musicbrainz-ngs that causes some
# strings to be bytes rather than Unicode.
@ -123,8 +126,8 @@ class AlbumInfo(object):
"""
for fld in ['album', 'artist', 'albumtype', 'label', 'artist_sort',
'catalognum', 'script', 'language', 'country', 'style',
'albumstatus', 'albumdisambig', 'releasegroupdisambig',
'artist_credit', 'media']:
'genre', 'albumstatus', 'albumdisambig', 'releasegroupdisambig',
'artist_credit', 'media', 'discogs_release_id', 'released_date']:
value = getattr(self, fld)
if isinstance(value, bytes):
setattr(self, fld, value.decode(codec, 'ignore'))

View file

@ -437,6 +437,8 @@ class Item(LibModel):
'albumartist_credit': types.STRING,
'genre': types.STRING,
'style': types.STRING,
'discogs_release_id': types.INTEGER,
'released_date': types.STRING,
'lyricist': types.STRING,
'composer': types.STRING,
'composer_sort': types.STRING,
@ -917,6 +919,8 @@ class Album(LibModel):
'album': types.STRING,
'genre': types.STRING,
'style': types.STRING,
'discogs_release_id': types.INTEGER,
'released_date': types.STRING,
'year': types.PaddedInt(4),
'month': types.PaddedInt(2),
'day': types.PaddedInt(2),
@ -962,6 +966,9 @@ class Album(LibModel):
'albumartist_credit',
'album',
'genre',
'style',
'discogs_release_id',
'released_date',
'year',
'month',
'day',

View file

@ -373,6 +373,7 @@ class BeatportPlugin(BeetsPlugin):
return None
release = self.client.get_release(match.group(2))
album = self._get_album_info(release)
print('ALBUM', album)
return album
def track_for_id(self, track_id):

View file

@ -303,7 +303,10 @@ class DiscogsPlugin(BeetsPlugin):
mediums = [t.medium for t in tracks]
country = result.data.get('country')
data_url = result.data.get('uri')
style = self.format_style(result.data.get('styles'))
style = self.format(result.data.get('styles'))
genre = self.format(result.data.get('genres'))
discogs_release_id = self.extract_release_id(result.data.get('uri'))
released_date = result.data.get('released')
# Extract information for the optional AlbumInfo fields that are
# contained on nested discogs fields.
@ -341,18 +344,21 @@ class DiscogsPlugin(BeetsPlugin):
day=None, label=label, mediums=len(set(mediums)),
artist_sort=None, releasegroup_id=master_id,
catalognum=catalogno, script=None, language=None,
country=country, style=style,
country=country, style=style, genre=genre,
albumstatus=None, media=media,
albumdisambig=None, artist_credit=None,
original_year=original_year, original_month=None,
original_day=None, data_source='Discogs',
data_url=data_url)
data_url=data_url, discogs_release_id=discogs_release_id, released_date=released_date)
def format_style(self, style):
if style is None:
self._log.debug('Style not Found')
def format(self, classification):
if classification is None:
self._log.debug('Classification not Found')
else:
return self.config['separator'].as_str().join(sorted(style))
return self.config['separator'].as_str().join(sorted(classification))
def extract_release_id(self, uri):
return uri.split("/")[-1]
def get_artist(self, artists):
"""Returns an artist string (all artists) and an artist_id (the main