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 8bbe8f4ea..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 ~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/plugins/zero.rst b/docs/plugins/zero.rst index 914e28faf..fed048330 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 23eb0e3cf..16ceaf56d 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -256,7 +256,8 @@ class ZeroPluginTest(IOMixin, 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( @@ -271,6 +272,7 @@ class ZeroPluginTest(IOMixin, 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) @@ -280,7 +282,8 @@ class ZeroPluginTest(IOMixin, 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) @@ -291,6 +294,7 @@ class ZeroPluginTest(IOMixin, 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(