Skip to content
Open
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
10 changes: 8 additions & 2 deletions beetsplug/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"isrcs",
"url-rels",
"release-rels",
"genres",
"tags",
}
& set(musicbrainzngs.VALID_INCLUDES["release"])
Expand Down Expand Up @@ -362,6 +363,10 @@


class MusicBrainzPlugin(MetadataSourcePlugin):
@cached_property
def genres_field(self) -> str | None:
return f"{config['musicbrainz']['genres_tag'].get()}-list"

def __init__(self):
"""Set up the python-musicbrainz-ngs module according to settings
from the beets configuration. This should be called at startup.
Expand All @@ -375,6 +380,7 @@
"ratelimit_interval": 1,
"searchlimit": 5,
"genres": False,
"genres_tag": "genre",
"external_ids": {
"discogs": False,
"bandcamp": False,
Expand Down Expand Up @@ -707,8 +713,8 @@

if self.config["genres"]:
sources = [
release["release-group"].get("tag-list", []),
release.get("tag-list", []),
release["release-group"].get(self.genres_field, []),
release.get(self.genres_field, []),

Check failure on line 717 in beetsplug/musicbrainz.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Argument 1 to "get" of "dict" has incompatible type "Optional[str]"; expected "str"
]
genres: Counter[str] = Counter()
for source in sources:
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ New features:
``played_ratio_threshold``, to allow configuring the percentage the song must
be played for it to be counted as played instead of skipped.
- :doc:`plugins/web`: Display artist and album as part of the search results.
- :doc:`plugins/musicbrainz`: Allow selecting tags or genres to populate the genres tag.

Bug fixes:

Expand Down
11 changes: 11 additions & 0 deletions docs/plugins/musicbrainz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Default
searchlimit: 5
extra_tags: []
genres: no
genres_tag: genre
external_ids:
discogs: no
bandcamp: no
Expand Down Expand Up @@ -124,6 +125,16 @@ Use MusicBrainz genre tags to populate (and replace if it's already set) the
and the release-group on MusicBrainz, separated by "; " and sorted by the total
number of votes. Default: ``no``

.. _genres_tag:

genres_tag
++++++++++

Either ``genres`` or ``tags``. Specify ``genres`` to use just musicbrainz genres
and ``tags`` to use all user-supplied musicbrainz tags.

Default: ``genres``

.. _musicbrainz.external_ids:

external_ids
Expand Down
Loading