From cd9f86ae6dc7cb2611da6c44d94a35da06a195c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20M=C3=B6llerstrand?= Date: Sun, 18 Jan 2026 15:29:59 +0100 Subject: [PATCH 1/2] feat: zero plugin zeroes disctotal if single disc When omit_single_disc is set, disctotal is now also zeroed alongside disc. Previously, only the disc tag was zeroed. --- beetsplug/zero.py | 8 +++----- docs/changelog.rst | 2 ++ docs/plugins/zero.rst | 5 ++--- test/plugins/test_zero.py | 8 ++++++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/beetsplug/zero.py b/beetsplug/zero.py index ab1bfa5ca..a72996ba5 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -123,12 +123,10 @@ class ZeroPlugin(BeetsPlugin): config. """ fields_set = False - - if "disc" in tags and self.config["omit_single_disc"].get(bool): - if item.disctotal == 1: + if self.config["omit_single_disc"].get(bool) and item.disctotal == 1: + for tag in {"disc", "disctotal"} & set(tags): + tags[tag] = None fields_set = True - self._log.debug("disc: {.disc} -> None", item) - tags["disc"] = None if not self.fields_to_progs: self._log.warning("no fields list to remove") diff --git a/docs/changelog.rst b/docs/changelog.rst index 3938d26a4..c8f8b2d72 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -94,6 +94,8 @@ New features ``beet import``. - :doc:`plugins/random`: Added ``--field`` option to specify which field to use for equal-chance sampling (default: ``albumartist``). +- :doc:`plugins/zero`: When the ``omit_single_disc`` option is set, + ``disctotal`` is zeroed alongside ``disc``. Bug fixes ~~~~~~~~~ diff --git a/docs/plugins/zero.rst b/docs/plugins/zero.rst index bf134e664..2f5b0796c 100644 --- a/docs/plugins/zero.rst +++ b/docs/plugins/zero.rst @@ -31,9 +31,8 @@ to nullify and the conditions for nullifying them: ``keep_fields``---not both! - To conditionally filter a field, use ``field: [regexp, regexp]`` to specify regular expressions. -- Set ``omit_single_disc`` to ``True`` to omit writing the ``disc`` number for - albums with only a single disc (``disctotal == 1``). By default, beets will - number the disc even if the album contains only one disc in total. +- Set ``omit_single_disc`` to ``True`` to omit writing the ``disc`` number and + the ``disctotal`` number for albums with a single disc (``disctotal == 1``). - By default this plugin only affects files' tags; the beets database is left unchanged. To update the tags in the database, set the ``update_database`` option to true. diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index b08bf0dca..f466a409e 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -261,7 +261,8 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.comments is None - assert mf.disc == 0 + assert mf.disc is None + assert mf.disctotal is None def test_omit_single_disc_with_tags_multi(self): item = self.add_item_fixture( @@ -276,6 +277,7 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.comments is None assert mf.disc == 1 + assert mf.disctotal == 4 def test_omit_single_disc_only_change_single(self): item = self.add_item_fixture(disctotal=1, disc=1) @@ -285,7 +287,8 @@ class ZeroPluginTest(PluginTestCase): item.write() mf = MediaFile(syspath(item.path)) - assert mf.disc == 0 + assert mf.disc is None + assert mf.disctotal is None def test_omit_single_disc_only_change_multi(self): item = self.add_item_fixture(disctotal=4, disc=1) @@ -296,6 +299,7 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.disc == 1 + assert mf.disctotal == 4 def test_empty_query_n_response_no_changes(self): item = self.add_item_fixture( From 5c3ba8e006ae4f9066dce9052a8c92fae6830c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Mon, 2 Mar 2026 16:38:02 +0000 Subject: [PATCH 2/2] Move changelog note under unreleased section --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fc1532cad..fe478c710 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -41,6 +41,8 @@ Bug fixes - :doc:`plugins/ftintitle`: Fix handling of multiple featured artists with ampersand. +- :doc:`plugins/zero`: When the ``omit_single_disc`` option is set, + ``disctotal`` is zeroed alongside ``disc``. For plugin developers ~~~~~~~~~~~~~~~~~~~~~ @@ -158,8 +160,6 @@ New features ``beet import``. - :doc:`plugins/random`: Added ``--field`` option to specify which field to use for equal-chance sampling (default: ``albumartist``). -- :doc:`plugins/zero`: When the ``omit_single_disc`` option is set, - ``disctotal`` is zeroed alongside ``disc``. Bug fixes ~~~~~~~~~