From 8fcff5ddc7bfef1394bedc39aa83614a7710d0ee Mon Sep 17 00:00:00 2001 From: Peter Koondial Date: Sun, 5 May 2019 11:11:27 +0200 Subject: [PATCH] Adding styles to discogs plugin --- beets/autotag/__init__.py | 1 + beets/config_default.yaml | 1 + beets/library.py | 4 +++- beetsplug/discogs.py | 10 +++++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index a71b9b0a6..48901f425 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/config_default.yaml b/beets/config_default.yaml index cf9ae6bf9..538753bb7 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -131,6 +131,7 @@ match: track_index: 1.0 track_length: 2.0 track_id: 5.0 + style: 5.0 preferred: countries: [] media: [] diff --git a/beets/library.py b/beets/library.py index 16db1e974..97ae4589c 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, @@ -495,7 +496,7 @@ class Item(LibModel): } _search_fields = ('artist', 'title', 'comments', - 'album', 'albumartist', 'genre') + 'album', 'albumartist') _types = { 'data_source': 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 5a2bf57e0..efc9f2b0e 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -302,6 +302,13 @@ class DiscogsPlugin(BeetsPlugin): mediums = [t.medium for t in tracks] country = result.data.get('country') data_url = result.data.get('uri') + style = result.data.get('styles') + if style is None: + self._log.info('Style not Found') + elif len(style) == 0: + return style + else: + style = ' - '.join(sorted(style)) # Extract information for the optional AlbumInfo fields that are # contained on nested discogs fields. @@ -339,7 +346,8 @@ 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',