diff --git a/beetsplug/zero.py b/beetsplug/zero.py index 05e55bfcde..a16830b96c 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -41,6 +41,7 @@ def __init__(self): "fields": [], "keep_fields": [], "update_database": False, + "zero_disc_number_if_single_disc": False, } ) @@ -123,8 +124,15 @@ 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 item.disctotal == 1: + self._log.debug("disc: {.disc} -> None", item) + tags["disc"] = None + if not self.fields_to_progs: - self._log.warning("no fields, nothing to do") + self._log.warning("no fields list to remove") return False for field, progs in self.fields_to_progs.items(): diff --git a/docs/changelog.rst b/docs/changelog.rst index 00e9a9e74a..0d1bff913a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -32,6 +32,8 @@ New features: ``played_ratio_threshold``, to allow configuring the percentage the song must be played for it to be counted as played instead of skipped. - :doc:`plugins/web`: Display artist and album as part of the search results. +- :doc:`plugins/zero`: Add new configurable ``zero_disc_number_if_single_disc`` + to allow zeroing the disc number on write for single-disc albums. Bug fixes: diff --git a/docs/plugins/zero.rst b/docs/plugins/zero.rst index 6ed9427d94..f478531287 100644 --- a/docs/plugins/zero.rst +++ b/docs/plugins/zero.rst @@ -31,6 +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 ``zero_disc_number_if_single_disc`` to ``True`` to zero the disc number + field only if the album contains a disctotal count and is a single disc. - 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.