mirror of
https://github.com/beetbox/beets.git
synced 2025-12-14 12:35:19 +01:00
Merge pull request #4304 from jdheyburn/jdheyburn-feat-discogs-append-style-to-genre
feat: discogs: allow style to be appended to genre
This commit is contained in:
commit
1bc00105bd
4 changed files with 47 additions and 1 deletions
|
|
@ -57,6 +57,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
'user_token': '',
|
||||
'separator': ', ',
|
||||
'index_tracks': False,
|
||||
'append_style_genre': False,
|
||||
})
|
||||
self.config['apikey'].redact = True
|
||||
self.config['apisecret'].redact = True
|
||||
|
|
@ -318,7 +319,13 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
country = result.data.get('country')
|
||||
data_url = result.data.get('uri')
|
||||
style = self.format(result.data.get('styles'))
|
||||
genre = self.format(result.data.get('genres'))
|
||||
base_genre = self.format(result.data.get('genres'))
|
||||
|
||||
if self.config['append_style_genre'] and style:
|
||||
genre = self.config['separator'].as_str().join([base_genre, style])
|
||||
else:
|
||||
genre = base_genre
|
||||
|
||||
discogs_albumid = self.extract_release_id(result.data.get('uri'))
|
||||
|
||||
# Extract information for the optional AlbumInfo fields that are
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ New features:
|
|||
:bug:`4101`
|
||||
* Add the item fields ``bitrate_mode``, ``encoder_info`` and ``encoder_settings``.
|
||||
* Add query prefixes ``=`` and ``~``.
|
||||
* :doc:`/plugins/discogs`: Permit appending style to genre
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,15 @@ whereas with ``index_tracks`` disabled you'd get::
|
|||
|
||||
This option is useful when importing classical music.
|
||||
|
||||
Other configurations available under ``discogs:`` are:
|
||||
|
||||
- **append_style_genre**: Appends the Discogs style (if found) to the genre tag. This can be useful if you want more granular genres to categorize your music.
|
||||
For example, a release in Discogs might have a genre of "Electronic" and a style of "Techno": enabling this setting would set the genre to be "Electronic, Techno" (assuming default separator of ``", "``) instead of just "Electronic".
|
||||
Default: ``false``
|
||||
- **separator**: How to join multiple genre and style values from Discogs into a string.
|
||||
Default: ``", "``
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ from test import _common
|
|||
from test._common import Bag
|
||||
from test.helper import capture_log
|
||||
|
||||
from beets import config
|
||||
|
||||
from beetsplug.discogs import DiscogsPlugin
|
||||
|
||||
|
||||
|
|
@ -373,6 +375,33 @@ class DGAlbumInfoTest(_common.TestCase):
|
|||
match = ''
|
||||
self.assertEqual(match, expected)
|
||||
|
||||
def test_default_genre_style_settings(self):
|
||||
"""Test genre default settings, genres to genre, styles to style"""
|
||||
release = self._make_release_from_positions(['1', '2'])
|
||||
|
||||
d = DiscogsPlugin().get_album_info(release)
|
||||
self.assertEqual(d.genre, 'GENRE1, GENRE2')
|
||||
self.assertEqual(d.style, 'STYLE1, STYLE2')
|
||||
|
||||
def test_append_style_to_genre(self):
|
||||
"""Test appending style to genre if config enabled"""
|
||||
config['discogs']['append_style_genre'] = True
|
||||
release = self._make_release_from_positions(['1', '2'])
|
||||
|
||||
d = DiscogsPlugin().get_album_info(release)
|
||||
self.assertEqual(d.genre, 'GENRE1, GENRE2, STYLE1, STYLE2')
|
||||
self.assertEqual(d.style, 'STYLE1, STYLE2')
|
||||
|
||||
def test_append_style_to_genre_no_style(self):
|
||||
"""Test nothing appended to genre if style is empty"""
|
||||
config['discogs']['append_style_genre'] = True
|
||||
release = self._make_release_from_positions(['1', '2'])
|
||||
release.data['styles'] = []
|
||||
|
||||
d = DiscogsPlugin().get_album_info(release)
|
||||
self.assertEqual(d.genre, 'GENRE1, GENRE2')
|
||||
self.assertEqual(d.style, None)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue