mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 04:52:49 +01:00
Merge pull request #3251 from thedevilisinthedetails/master
#2579 Adding styles to discogs plugin
This commit is contained in:
commit
ed30a7aed2
5 changed files with 20 additions and 4 deletions
|
|
@ -161,6 +161,7 @@ def apply_metadata(album_info, mapping):
|
|||
'script',
|
||||
'language',
|
||||
'country',
|
||||
'style',
|
||||
'albumstatus',
|
||||
'albumdisambig',
|
||||
'releasegroupdisambig',
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ class DGAlbumInfoTest(_common.TestCase):
|
|||
'name': 'FORMAT',
|
||||
'qty': 1
|
||||
}],
|
||||
'styles': [
|
||||
'STYLE1', 'STYLE2'
|
||||
],
|
||||
'labels': [{
|
||||
'name': 'LABEL NAME',
|
||||
'catno': 'CATALOG NUMBER',
|
||||
|
|
|
|||
Loading…
Reference in a new issue