diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index d246e1d9f..cb7d8e26f 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -25,6 +25,7 @@ import beets.autotag.hooks import beets from beets import util from beets import config +from collections import Counter from urllib.parse import urljoin VARIOUS_ARTISTS_ID = '89ad4ac3-39f7-470e-963a-56509c546377' @@ -454,9 +455,17 @@ def album_info(release): first_medium = release['medium-list'][0] info.media = first_medium.get('format') - genres = release.get('genre-list') - if config['musicbrainz']['genres'] and genres: - info.genre = ';'.join(g['name'] for g in genres) + if config['musicbrainz']['genres']: + sources = [ + release['release-group'].get('genre-list', []), + release.get('genre-list', []), + ] + genres = Counter() + for source in sources: + for genreitem in source: + genres[genreitem['name']] += int(genreitem['count']) + info.genre = '; '.join(g[0] for g in sorted(genres.items(), + key=lambda g: -g[1])) extra_albumdatas = plugins.send('mb_album_extract', data=release) for extra_albumdata in extra_albumdatas: diff --git a/docs/changelog.rst b/docs/changelog.rst index 800230e46..1a0424811 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -9,11 +9,17 @@ This release now requires Python 3.6 or later (it removes support for Python For packagers: -+* We fixed a flaky test, named `test_album_art` in the `test_zero.py` file, +* We fixed a flaky test, named `test_album_art` in the `test_zero.py` file, that some distributions had disabled. Disabling this test should no longer be necessary. :bug:`4037` :bug:`4038` +Major new features: + +* Include the genre tags from the release group when the musicbrainz genre + option is set, and sort them by the number of votes. Thanks to + :user:`aereaux`. + 1.5.0 (August 19, 2021) ----------------------- diff --git a/docs/reference/config.rst b/docs/reference/config.rst index aabe732c2..cc85cd269 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -753,10 +753,10 @@ Default: ``[]`` genres ~~~~~~ -Use MusicBrainz genre tags to populate the ``genre`` tag. This will make it a -semicolon-separated list of all the genres tagged for the release on -MusicBrainz. - +Use MusicBrainz genre tags to populate (and replace if it's already set) the +``genre`` tag. This will make it a list of all the genres tagged for the +release and the release-group on MusicBrainz, separated by "; " and sorted by +the total number of votes. Default: ``no`` .. _match-config: