Skip to content

Adds a zero_disc_number_if_single_disc to the zero plugin #5909

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 3 commits into
base: master
Choose a base branch
from

Conversation

michaelkrieger
Copy link

@michaelkrieger michaelkrieger commented Jul 31, 2025

Adds a zero_disc_number_if_single_disc boolean to the zero plugin for writing to files. Adds the logic that, if disctotal is set and there is only one disc in disctotal, that the disc is not set.

This keeps tags cleaner, only using disc on multi-disc albums. The disctotal is not touched, particularly as this is not usually displayed in most clients.

The field is removed only for writing the tags, but the disc number is maintained in the database to avoid breaking anything that may depend on a disc number or avoid possible loops or failed logic.

A column of disc 1 makes me feel there should be a disc 2, when most albums are a single disc only.

Description

This addresses concerns such as https://beets-users.narkive.com/fxh0cgmC/beets-remove-disc-field-for-single-disc-albums and accomplishes things like #5670 but in tags instead of just in the path.

To Do

  • Tests. (Very much encouraged but not strictly required.)

Adds a `zero_disc_number_if_single_disc` boolean to the zero plugin for writing to files.  Adds the logic that, if disctotal is set and there is only one disc in disctotal, that the disc is not set.

This keeps tags cleaner, only using disc on multi-disc albums.
The disctotal is not touched, particularly as this is not usually displayed in most clients.

The field is kept only for writing the tags, but the disc number is maintained in the database.
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.71%. Comparing base (2680750) to head (2a161c9).

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

@michaelkrieger
Copy link
Author

Would love to hear some feedback on this or its implementation.

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.

Note the failing CI check - you need run poe format to make sure the changes are formatted consistently.

@@ -123,8 +124,13 @@ def set_fields(self, item, tags):
"""
fields_set = False

if 'disc' in tags and self.config["zero_disc_number_if_single_disc"].get(bool):
if getattr(item, 'disctotal', None) == 1:
Copy link
Member

Choose a reason for hiding this comment

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

I think you can access this attribute directly

Suggested change
if getattr(item, 'disctotal', None) == 1:
if item.disctotal == 1:

@@ -123,8 +124,13 @@ def set_fields(self, item, tags):
"""
fields_set = False

if 'disc' in tags and self.config["zero_disc_number_if_single_disc"].get(bool):
if getattr(item, 'disctotal', None) == 1:
self._log.debug("{0}: {1} -> None", 'disc', item['disc'])
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
self._log.debug("{0}: {1} -> None", 'disc', item['disc'])
self._log.debug("disc: {.disc} -> None", item)

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