Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion beetsplug/zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self):
"fields": [],
"keep_fields": [],
"update_database": False,
"zero_disc_number_if_single_disc": False
}
)

Expand Down Expand Up @@ -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'])
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():
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ New features:
* :doc:`plugins/mpdstats`: Add new configuration option,
``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/zero`: Add new configuration option,
``zero_disc_number_if_single_disc``, to allow zeroing the disc number on
write for single-disc albums. Defaults to False.

Bug fixes:

Expand Down
2 changes: 2 additions & 0 deletions docs/plugins/zero.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ fields to nullify and the conditions for nullifying them:
``fields`` or ``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.

Expand Down
Loading