Skip to content

Change missing plugin to allow for filtering albums by release type#5587

Open
bgrassy wants to merge 8 commits intobeetbox:masterfrom
bgrassy:update_missing_album_plugin
Open

Change missing plugin to allow for filtering albums by release type#5587
bgrassy wants to merge 8 commits intobeetbox:masterfrom
bgrassy:update_missing_album_plugin

Conversation

@bgrassy
Copy link

@bgrassy bgrassy commented Jan 11, 2025

Description

Addresses #2661.

Currently, the missing plugin when ran in album mode only allows for getting all release groups attached to a single artist. Users may want to restrict this search to only show releases of a specific type (such as albums or compilations). This CR adds a new --release-type flag to the missing plugin. If users want to filter to a specific type (or set of types), they simply need to provide this flag for every release type that they want included.

As part of this change, the default behavior has been shifted to only select album type releases as is suggested in the issue- to avoid breaking default behavior I could easily switch this back. I am also wondering if it might make sense to address the following idea (#5101) in a follow-up.
Bug fix: This change also fixes a bug where --album mode incorrectly reported albums already in the library as missing. The original code compared release group IDs from MusicBrainz against Album objects (which never matched). This now correctly compares against mb_releasegroupid.

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.)

@snejus snejus requested a review from a team as a code owner October 14, 2025 22:30
@bgrassy bgrassy force-pushed the update_missing_album_plugin branch from d9b17ca to 1079b13 Compare November 28, 2025 16:18
@JOJ0 JOJ0 added the plugin Pull requests that are plugins related label Jan 10, 2026
@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.63%. Comparing base (3bcc539) to head (165a79e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5587      +/-   ##
==========================================
+ Coverage   69.55%   69.63%   +0.08%     
==========================================
  Files         141      141              
  Lines       18498    18504       +6     
  Branches     3026     3027       +1     
==========================================
+ Hits        12867    12886      +19     
+ Misses       4995     4982      -13     
  Partials      636      636              
Files with missing lines Coverage Δ
beetsplug/_utils/musicbrainz.py 92.91% <100.00%> (+0.05%) ⬆️
beetsplug/missing.py 77.27% <100.00%> (+19.44%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgrassy bgrassy force-pushed the update_missing_album_plugin branch 2 times, most recently from 96406c7 to dda1e83 Compare February 4, 2026 21:32
@snejus snejus self-requested a review as a code owner February 23, 2026 05:09
Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

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

Apologies for a very late review, one question

@bgrassy bgrassy force-pushed the update_missing_album_plugin branch from dda1e83 to b5cf224 Compare March 13, 2026 22:15
"count": False,
"total": False,
"album": False,
"release_type": ["album"],
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_type": ["album"],
"release_types": ["album"],

album_ids_by_artist[artist].add(album["mb_releasegroupid"])

total_missing = 0
release_type = self.config["release_type"].get() or ["album"]
Copy link
Member

Choose a reason for hiding this comment

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

  1. Call as_str_seq() here to make sure it handles release_types: a b c
  2. No need to default to ["album"] as that's already the default. I think we should leave users the option to specify an empty list release_types: [].
Suggested change
release_type = self.config["release_type"].get() or ["album"]
release_type = self.config["release_type"].as_str_seq()

Copy link
Author

Choose a reason for hiding this comment

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

I changed the default on line 229 (still have the question linked to below surrounding if we actually want this default to be ["album"])

resp = self.mb_api.browse_release_groups(artist=artist_id)
resp = self.mb_api.browse_release_groups(
artist=artist_id,
type="|".join(release_type),
Copy link
Member

Choose a reason for hiding this comment

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

Given my comment above, we may have an empty list here. What happens if we submit type="" to MB API? If the results are the same as if no types are supplied, then we can leave it as it is.

Otherwise, maybe we should check that the list is not empty and only then supply this argument?

Copy link
Author

Choose a reason for hiding this comment

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

Just checked this- type="" returns the same results as not passing type, so I left it as is. One question though- this does change default behavior from running no type filter to filtering just to --release-type album. Should I instead set the default to empty in the config?

Copy link
Member

Choose a reason for hiding this comment

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

Is it still possible to override this with missing: release_types: [] using the config?

Copy link
Member

Choose a reason for hiding this comment

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

By the way, rename the flag to --release-types as well!

Copy link
Author

Choose a reason for hiding this comment

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

Renamed (and changed the flag to support comma separated multiple inputs). One of the tests checks that release_types: [] in the config passes an empty type string to the musicbrainz request, so that should match that behavior.

Bug fixes
~~~~~~~~~

- :doc:`plugins/missing`: Fix ``--album`` mode incorrectly reporting albums
Copy link
Member

Choose a reason for hiding this comment

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

Love it!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

PR add new missing --release-type filter for album mode, and fix bug where album mode mark albums already in library as missing (now compare against mb_releasegroupid).

Changes:

  • Add --release-type flag (repeatable) and default album-mode browse to type=album.
  • Fix missing-album detection by comparing MB release-group IDs to Album.mb_releasegroupid.
  • Update tests + docs + changelog; extend MusicBrainz browse kwargs to accept type.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
beetsplug/missing.py Add release-type filtering and fix comparison to use mb_releasegroupid.
beetsplug/_utils/musicbrainz.py Allow type kwarg for browsing release-groups; route through _browse.
test/plugins/test_missing.py Add regression test for mb_releasegroupid compare + new release-type tests.
docs/plugins/missing.rst Document --release-type usage and examples.
docs/changelog.rst Add entries for new flag + bug fix.

You can also share your feedback on Copilot code review. Take the survey.

@bgrassy bgrassy force-pushed the update_missing_album_plugin branch from 72429e2 to b38e8fc Compare March 14, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin Pull requests that are plugins related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants