diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index a71b9b0a61..48901f4252 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -155,6 +155,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 ec7047b7c7..b8e6108b4e 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -79,8 +79,8 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, 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 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, 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 @@ def decode(self, codec='utf-8'): 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 16db1e974d..c7fbe48cf6 100644 --- a/beets/library.py +++ b/beets/library.py @@ -436,6 +436,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, @@ -915,6 +916,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 5a2bf57e04..f6197ddba6 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -55,6 +55,7 @@ def __init__(self): '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 @@ def get_album_info(self, result): 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 @@ def get_album_info(self, result): 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 8b2eff9f1d..0acf54e8a2 100644 --- a/test/test_discogs.py +++ b/test/test_discogs.py @@ -45,6 +45,9 @@ def _make_release(self, tracks=None): 'name': 'FORMAT', 'qty': 1 }], + 'styles': [ + 'STYLE1', 'STYLE2' + ], 'labels': [{ 'name': 'LABEL NAME', 'catno': 'CATALOG NUMBER', diff --git a/tox.ini b/tox.ini index e3250bd6b5..8736f0f3c0 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py27-test, py37-test, py38-test, py27-flake8, docs +envlist = py27-test, py37-test, py27-flake8, docs # The exhaustive list of environments is: # envlist = py{27,34,35}-{test,cov}, py{27,34,35}-flake8, docs