Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add discogs_labelid and discogs_artistid fields #3413

Merged
merged 2 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions beets/autotag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def apply_metadata(album_info, mapping):
'style',
'genre',
'discogs_albumid',
'discogs_artistid',
'discogs_labelid',
'albumstatus',
'albumdisambig',
'releasegroupdisambig',
Expand Down
8 changes: 6 additions & 2 deletions beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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'))
Expand Down
6 changes: 6 additions & 0 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -981,6 +985,8 @@ class Album(LibModel):
'genre',
'style',
'discogs_albumid',
'discogs_artistid',
'discogs_labelid',
'year',
'month',
'day',
Expand Down
6 changes: 4 additions & 2 deletions beetsplug/discogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,15 @@ 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
media = result.data['formats'][0]['name']
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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down