mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Adds a zero_disc_if_single_disc to the zero plugin
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.
This commit is contained in:
parent
41e314247d
commit
33b350a612
3 changed files with 11 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ class ZeroPlugin(BeetsPlugin):
|
|||
"fields": [],
|
||||
"keep_fields": [],
|
||||
"update_database": False,
|
||||
"zero_disc_if_single_disc": False,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -123,8 +124,12 @@ class ZeroPlugin(BeetsPlugin):
|
|||
"""
|
||||
fields_set = False
|
||||
|
||||
if "disc" in tags and self.config["zero_disc_if_single_disc"].get(bool) and 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():
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ Unreleased
|
|||
----------
|
||||
|
||||
New features:
|
||||
* :doc:`plugins/zero`: Add new configuration option,
|
||||
``zero_disc_if_single_disc``, to allow zeroing the disc number on
|
||||
write for single-disc albums. Defaults to False.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -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_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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue