diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index ede4fbe12..df0d94abb 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -161,6 +161,7 @@ def apply_metadata(album_info, mapping): 'script', 'language', 'country', + 'style', 'albumstatus', 'albumdisambig', 'releasegroupdisambig', diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 57cd1c309..27db4fad7 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -79,8 +79,8 @@ 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, albumstatus=None, media=None, - albumdisambig=None, releasegroupdisambig=None, + language=None, country=None, style=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): self.album = album @@ -102,6 +102,7 @@ class AlbumInfo(object): self.script = script self.language = language self.country = country + self.style = style self.albumstatus = albumstatus self.media = media self.albumdisambig = albumdisambig @@ -121,7 +122,7 @@ class AlbumInfo(object): constituent `TrackInfo` objects, are decoded to Unicode. """ for fld in ['album', 'artist', 'albumtype', 'label', 'artist_sort', - 'catalognum', 'script', 'language', 'country', + 'catalognum', 'script', 'language', 'country', 'style', 'albumstatus', 'albumdisambig', 'releasegroupdisambig', 'artist_credit', 'media']: value = getattr(self, fld) diff --git a/beets/library.py b/beets/library.py index bb49d0e99..0555b9baf 100644 --- a/beets/library.py +++ b/beets/library.py @@ -448,6 +448,7 @@ class Item(LibModel): 'albumartist_sort': types.STRING, 'albumartist_credit': types.STRING, 'genre': types.STRING, + 'style': types.STRING, 'lyricist': types.STRING, 'composer': types.STRING, 'composer_sort': types.STRING, @@ -930,6 +931,7 @@ class Album(LibModel): 'albumartist_credit': types.STRING, 'album': types.STRING, 'genre': types.STRING, + 'style': types.STRING, 'year': types.PaddedInt(4), 'month': types.PaddedInt(2), 'day': types.PaddedInt(2), diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 6a0a9c531..e97772af6 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -55,6 +55,7 @@ class DiscogsPlugin(BeetsPlugin): 'tokenfile': 'discogs_token.json', 'source_weight': 0.5, 'user_token': '', + 'separator': u', ' }) self.config['apikey'].redact = True self.config['apisecret'].redact = True @@ -302,6 +303,7 @@ 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')) # Extract information for the optional AlbumInfo fields that are # contained on nested discogs fields. @@ -339,12 +341,19 @@ 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, albumstatus=None, media=media, + country=country, style=style, + 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) + def format_style(self, style): + if style is None: + self._log.debug('Style not Found') + else: + return self.config['separator'].as_str().join(sorted(style)) + def get_artist(self, artists): """Returns an artist string (all artists) and an artist_id (the main artist) for a list of discogs album or track artists. diff --git a/test/test_discogs.py b/test/test_discogs.py index 8b2eff9f1..0acf54e8a 100644 --- a/test/test_discogs.py +++ b/test/test_discogs.py @@ -45,6 +45,9 @@ class DGAlbumInfoTest(_common.TestCase): 'name': 'FORMAT', 'qty': 1 }], + 'styles': [ + 'STYLE1', 'STYLE2' + ], 'labels': [{ 'name': 'LABEL NAME', 'catno': 'CATALOG NUMBER',