Skip to content

Add --remove option to duplicates plugin #5832

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

Merged
merged 4 commits into from
Jul 6, 2025
Merged

Add --remove option to duplicates plugin #5832

merged 4 commits into from
Jul 6, 2025

Conversation

JOJ0
Copy link
Member

@JOJ0 JOJ0 commented Jun 22, 2025

Description

The duplicates plugin currently only supports deleting files entirely, sometimes it's desired to only fix the library and keep files in place. This PR adds this possibility.

  • Documentation.
  • Changelog. (will add after review)
  • Tests.

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.

@JOJ0 JOJ0 marked this pull request as ready for review June 22, 2025 06:55
@Copilot Copilot AI review requested due to automatic review settings June 22, 2025 06:55
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.

Copy link
Contributor

@Copilot 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

This PR introduces a new --remove option to the duplicates plugin so users can unlink items from the library without deleting their files.

  • Added configuration and parsing for the --remove flag
  • Updated the item-processing logic to handle remove vs delete
  • Extended documentation to describe the new option

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docs/plugins/duplicates.rst Documented the --remove option and its default configuration
beetsplug/duplicates.py Added remove to config defaults, CLI parser, and processing
Comments suppressed due to low confidence (3)

beetsplug/duplicates.py:140

  • [nitpick] Clarify the help text to indicate that this option leaves files on disk (e.g., help="remove items from library, but not from disk") so users understand the difference from --delete.
            help="remove items from library",

beetsplug/duplicates.py:56

  • Add unit tests for the --remove option to verify that items are removed from the library without deleting their files.
                "remove": False,

docs/plugins/duplicates.rst:99

  • [nitpick] Include an example demonstrating the new --remove flag (for example, beet duplicates -x) in the Examples section to illustrate its usage.
Examples

@JOJ0 JOJ0 force-pushed the dupremove branch 2 times, most recently from e9fae53 to 3d5f685 Compare July 2, 2025 06:21
@JOJ0 JOJ0 enabled auto-merge July 2, 2025 06:33
@JOJ0
Copy link
Member Author

JOJ0 commented Jul 2, 2025

I added a changelog entry and enabled auto-merge. If there's nothing else missing or worth noticing could you give the approval @wisp3rwind ? Thanks a lot!

@JOJ0 JOJ0 disabled auto-merge July 3, 2025 08:59
@JOJ0
Copy link
Member Author

JOJ0 commented Jul 3, 2025

I disabled auto-merge. When I get an approval from anyone @wisp3rwind @snejus I will press the merge button myself. Please approve it's a tiny change. Thanks!

Copy link
Member

@wisp3rwind wisp3rwind left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 👍
(Small nitpick: The only other command with a --remove option is mbupdate apparently, which uses -r for the short form. Maybe, duplicates should do so as well instead of -x?)

(Note that I'm not really familiar with the duplicates plugin.)

It looks a bit like the plugin still isn't properly handling conflicting action options (what happens if --delete and --tag are given? Calling item.store() after item.remove() looks a little concerning). Probably, (some) actions should be made exclusive (at least upon executing them, maybe also warning the user about it).

Anyway, that's not a regression of this PR, but an issue that existed before.

@JOJ0
Copy link
Member Author

JOJ0 commented Jul 5, 2025

LGTM, thanks 👍 (Small nitpick: The only other command with a --remove option is mbupdate apparently, which uses -r for the short form. Maybe, duplicates should do so as well instead of -x?)

Thanks for checking options. I did a grep in the codebase now and I think you mean the mbcollection plugin (mbupdate is the command, oh I see, never used it ;-)).

I think I'm too invested in UNIX programs and -r makes me think of --recursive, thus my choice. Anyway I'll change it to -r for consistency.

BTW I tried the mbcollection plugin and I get an API error even though I think I configured my musicibrainz section correctly in my beets conf. Not sure if this plugin is functioning anymore but only invested 5 minutes for it. Does it work for you maybe?

(Note that I'm not really familiar with the duplicates plugin.)

Same here.

It looks a bit like the plugin still isn't properly handling conflicting action options (what happens if --delete and --tag are given? Calling item.store() after item.remove() looks a little concerning). Probably, (some) actions should be made exclusive (at least upon executing them, maybe also warning the user about it).

Exactly, I briefly noted that here: #5832 (comment) but still I am unsure if some of them make sense together. Some definitely do not!

Anyway, that's not a regression of this PR, but an issue that existed before.

I'll merge it and make your post a new feature/refactor request.

Removes from library but keeps files.
JOJ0 and others added 2 commits July 5, 2025 07:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wisp3rwind
Copy link
Member

Thanks for checking options. I did a grep in the codebase now and I think you mean the mbcollection plugin (mbupdate is the command, oh I see, never used it ;-)).

I think I'm too invested in UNIX programs and -r makes me think of --recursive, thus my choice. Anyway I'll change it to -r for consistency.

Yeah, it's probably always somewhat ambiguous. I'm not sure how much mbcollection is used, so I guess we could also consider changing which short form beets uses for --remove. It'd be nice to be consistent, however. Note that chown/chmod have -R though, and grep has both -r and -R, so there's no really universal standard.

BTW I tried the mbcollection plugin and I get an API error even though I think I configured my musicibrainz section correctly in my beets conf. Not sure if this plugin is functioning anymore but only invested 5 minutes for it. Does it work for you maybe?

No, I've never used it, only grepped for --remove.

Exactly, I briefly noted that here: #5832 (comment) but still I am unsure if some of them make sense together. Some definitely do not!

Anyway, that's not a regression of this PR, but an issue that existed before.

I'll merge it and make your post a new feature/refactor request.

👍

@JOJ0 JOJ0 merged commit 2a896d4 into master Jul 6, 2025
20 checks passed
@JOJ0 JOJ0 deleted the dupremove branch July 6, 2025 06:56
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