From d70287df009fd366429dcf1cecc8f0b8a3f8bef1 Mon Sep 17 00:00:00 2001 From: Aidan Epstein Date: Fri, 23 Oct 2020 15:29:29 -0700 Subject: [PATCH 1/2] Add genre support using musicbrainz tags. This requires this PR: https://github.com/alastair/python-musicbrainzngs/pull/266 --- beets/autotag/mb.py | 5 +++++ docs/changelog.rst | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index ea8ef24da7..06b088fd40 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -74,6 +74,8 @@ def get_message(self): TRACK_INCLUDES = ['artists', 'aliases'] if 'work-level-rels' in musicbrainzngs.VALID_INCLUDES['recording']: TRACK_INCLUDES += ['work-level-rels', 'artist-rels'] +if 'genres' in musicbrainzngs.VALID_INCLUDES['recording']: + RELEASE_INCLUDES += ['genres'] def track_url(trackid): @@ -415,6 +417,9 @@ def album_info(release): first_medium = release['medium-list'][0] info.media = first_medium.get('format') + if release.get('genre-list'): + info.genre = ';'.join(g['name'] for g in release['genre-list']) + info.decode() return info diff --git a/docs/changelog.rst b/docs/changelog.rst index e65e6b1e91..25b1d7b82b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -159,6 +159,11 @@ New features: * :doc:`/plugins/web`: add DELETE and PATCH methods for modifying items * :doc:`/plugins/lyrics`: Removed LyricWiki source (shut down on 21/09/2020). * Added a ``--plugins`` (or ``-p``) flag to specify a list of plugins at startup. +* Use musicbrainz genre tag api to get genre information. This currently + depends on functionality that is currently unreleased in musicbrainzngs. + See https://github.com/alastair/python-musicbrainzngs/pull/247 and + https://github.com/alastair/python-musicbrainzngs/pull/266 . + Thanks to :user:`aereaux`. Fixes: From d011a4e5778fcf1422d88b8ae9a3cbd89cc97670 Mon Sep 17 00:00:00 2001 From: Aidan Epstein Date: Wed, 28 Oct 2020 19:31:31 +0000 Subject: [PATCH 2/2] Update beets/autotag/mb.py Co-authored-by: Adrian Sampson --- beets/autotag/mb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 06b088fd40..211f4c42fd 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -417,8 +417,9 @@ def album_info(release): first_medium = release['medium-list'][0] info.media = first_medium.get('format') - if release.get('genre-list'): - info.genre = ';'.join(g['name'] for g in release['genre-list']) + genres = release.get('genre-list') + if genres: + info.genre = ';'.join(g['name'] for g in genres) info.decode() return info