From 1f665b02903bc647ae5f4a1edce67cec9f5029d6 Mon Sep 17 00:00:00 2001 From: msil Date: Thu, 24 Oct 2019 10:13:37 +0000 Subject: [PATCH 1/2] adding `discogs_labelid` and `discogs_artistid` fields --- beets/autotag/__init__.py | 2 ++ beets/autotag/hooks.py | 8 ++++++-- beets/library.py | 6 ++++++ beetsplug/discogs.py | 6 ++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index ee1bf051c5..f9e38413e2 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -170,6 +170,8 @@ def apply_metadata(album_info, mapping): 'style', 'genre', 'discogs_albumid', + 'discogs_artistid', + 'discogs_labelid', 'albumstatus', 'albumdisambig', 'releasegroupdisambig', diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index c0f0ace7be..030f371ba3 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -84,7 +84,8 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, releasegroupdisambig=None, artist_credit=None, original_year=None, original_month=None, original_day=None, data_source=None, data_url=None, - discogs_albumid=None): + discogs_albumid=None, discogs_labelid=None, + discogs_artistid=None): self.album = album self.album_id = album_id self.artist = artist @@ -117,6 +118,8 @@ def __init__(self, album, album_id, artist, artist_id, tracks, asin=None, self.data_source = data_source self.data_url = data_url self.discogs_albumid = discogs_albumid + self.discogs_labelid = discogs_labelid + self.discogs_artistid = discogs_artistid # Work around a bug in python-musicbrainz-ngs that causes some # strings to be bytes rather than Unicode. @@ -129,7 +132,8 @@ def decode(self, codec='utf-8'): 'catalognum', 'script', 'language', 'country', 'style', 'genre', 'albumstatus', 'albumdisambig', 'releasegroupdisambig', 'artist_credit', - 'media', 'discogs_albumid']: + 'media', 'discogs_albumid', 'discogs_labelid', + 'discogs_artistid']: value = getattr(self, fld) if isinstance(value, bytes): setattr(self, fld, value.decode(codec, 'ignore')) diff --git a/beets/library.py b/beets/library.py index 59791959d6..5d90ae43bd 100644 --- a/beets/library.py +++ b/beets/library.py @@ -450,6 +450,8 @@ class Item(LibModel): 'genre': types.STRING, 'style': types.STRING, 'discogs_albumid': types.INTEGER, + 'discogs_artistid': types.INTEGER, + 'discogs_labelid': types.INTEGER, 'lyricist': types.STRING, 'composer': types.STRING, 'composer_sort': types.STRING, @@ -934,6 +936,8 @@ class Album(LibModel): 'genre': types.STRING, 'style': types.STRING, 'discogs_albumid': types.INTEGER, + 'discogs_artistid': types.INTEGER, + 'discogs_labelid': types.INTEGER, 'year': types.PaddedInt(4), 'month': types.PaddedInt(2), 'day': types.PaddedInt(2), @@ -981,6 +985,8 @@ class Album(LibModel): 'genre', 'style', 'discogs_albumid', + 'discogs_artistid', + 'discogs_labelid', 'year', 'month', 'day', diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index bccf1f7e2b..1437c970e6 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -325,7 +325,7 @@ def get_album_info(self, result): # Extract information for the optional AlbumInfo fields that are # contained on nested discogs fields. - albumtype = media = label = catalogno = None + albumtype = media = label = catalogno = labelid = None if result.data.get('formats'): albumtype = ', '.join( result.data['formats'][0].get('descriptions', [])) or None @@ -333,6 +333,7 @@ def get_album_info(self, result): if result.data.get('labels'): label = result.data['labels'][0].get('name') catalogno = result.data['labels'][0].get('catno') + labelid = result.data['labels'][0].get('id') # Additional cleanups (various artists name, catalog number, media). if va: @@ -365,7 +366,8 @@ def get_album_info(self, result): original_year=original_year, original_month=None, original_day=None, data_source='Discogs', data_url=data_url, - discogs_albumid=discogs_albumid) + discogs_albumid=discogs_albumid, + discogs_labelid=labelid, discogs_artistid=artist_id) def format(self, classification): if classification: From 700b9a64ee2f267fd2cedc5fb285d0822d59a0b3 Mon Sep 17 00:00:00 2001 From: msil Date: Thu, 24 Oct 2019 15:24:49 +0100 Subject: [PATCH 2/2] update changelog --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 15958a0ead..169da71ba7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,9 @@ Changelog New features: +* :doc:`plugins/discogs` now adds two extra fields: `discogs_labelid` and + `discogs_artistid` + :bug: `3413` * :doc:`/plugins/export`: Added new ``-f`` (``--format``) flag; which allows for the ability to export in json, csv and xml. Thanks to :user:`austinmm`.