Skip to content

Allow selecting either tags or genres in the includes, defaulting to genres #5874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aereaux
Copy link
Contributor

@aereaux aereaux commented Jul 15, 2025

Description

Genres is a filtered list based on what musicbrainz considers a genre, tags are all the user-submitted tags. [1]

  1. https://musicbrainz.org/doc/MusicBrainz_API#:~:text=Since%20genres%20are,!).

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@aereaux aereaux force-pushed the genre-or-tag branch 7 times, most recently from 4698b56 to e348566 Compare July 16, 2025 19:48
…genres

Genres is a filtered list based on what musicbrainz considers a genre,
tags are all the user-submitted tags. [1]

1. https://musicbrainz.org/doc/MusicBrainz_API#:~:text=Since%20genres%20are,!).
Copy link

codecov bot commented Aug 3, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.70%. Comparing base (5beb3d1) to head (7ac6afc).

Files with missing lines Patch % Lines
beetsplug/musicbrainz.py 20.00% 6 Missing and 2 partials ⚠️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +399 to +409
genres_config = config["musicbrainz"]["genres"]
if genres_config:
genres_config = genres_config.get(str)
if genres_config == "genres":
self.genre_or_tag = "genre"
elif genres_config == "tags":
self.genre_or_tag = "tag"
else:
self.genre_or_tag = "genre"
else:
self.genre_or_tag = False
Copy link
Member

@snejus snejus Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this tidier, define this as a genres_field cached_property above the __init__ method

Suggested change
genres_config = config["musicbrainz"]["genres"]
if genres_config:
genres_config = genres_config.get(str)
if genres_config == "genres":
self.genre_or_tag = "genre"
elif genres_config == "tags":
self.genre_or_tag = "tag"
else:
self.genre_or_tag = "genre"
else:
self.genre_or_tag = False
def genres_field(self) -> str | None:
return f"{config['musicbrainz']['genres_tag'].get()}-list"
  • Use a separate configuration field genres_tag that can be either genre or tag
  • Use f-string to concatenate it with -list to return the field name to be used later

@@ -705,10 +717,10 @@ def album_info(self, release: JSONDict) -> beets.autotag.hooks.AlbumInfo:
else:
info.media = "Media"

if self.config["genres"]:
if self.genre_or_tag:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the same logic here

Suggested change
if self.genre_or_tag:
if self.config["genres"]:

Comment on lines +722 to +723
release["release-group"].get(self.genre_or_tag + "-list", []),
release.get(self.genre_or_tag + "-list", []),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
release["release-group"].get(self.genre_or_tag + "-list", []),
release.get(self.genre_or_tag + "-list", []),
release["release-group"].get(self.genres_field, []),
release.get(self.genres_field, []),

Comment on lines +123 to +124
the total number of votes. Specify "genres" to use just musicbrainz genres and
"tags" to use all user-supplied musicbrainz tags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the genre configuration unchanged to make sure that this change is backwards-compatible.

Instead, add a new configuration genres_tag which can take either genre or tag as a value, defaulting to genre. Make it clear that this configuration is only used when genres configuration is enabled.

You will need to specify the default in the self.config.add call under the __init__ method:

                 "searchlimit": 5,
                 "genres": False,
+                "genres_tag": "genre",
                 "external_ids": {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants