-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: master
Are you sure you want to change the base?
Conversation
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. |
4698b56
to
e348566
Compare
…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,!).
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
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 |
There was a problem hiding this comment.
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
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: |
There was a problem hiding this comment.
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
if self.genre_or_tag: | |
if self.config["genres"]: |
release["release-group"].get(self.genre_or_tag + "-list", []), | ||
release.get(self.genre_or_tag + "-list", []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, []), |
the total number of votes. Specify "genres" to use just musicbrainz genres and | ||
"tags" to use all user-supplied musicbrainz tags. |
There was a problem hiding this comment.
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": {
Description
Genres is a filtered list based on what musicbrainz considers a genre, tags are all the user-submitted tags. [1]
To Do
docs/
to describe it.)docs/changelog.rst
to the bottom of one of the lists near the top of the document.)