mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
zero: optionally update tags in the database.
This commit is contained in:
parent
ab5a4e2450
commit
71d3be238b
4 changed files with 27 additions and 2 deletions
|
|
@ -41,6 +41,7 @@ class ZeroPlugin(BeetsPlugin):
|
||||||
|
|
||||||
self.config.add({
|
self.config.add({
|
||||||
'fields': [],
|
'fields': [],
|
||||||
|
'update_database': False,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.patterns = {}
|
self.patterns = {}
|
||||||
|
|
@ -99,3 +100,5 @@ class ZeroPlugin(BeetsPlugin):
|
||||||
if match:
|
if match:
|
||||||
self._log.debug(u'{0}: {1} -> None', field, value)
|
self._log.debug(u'{0}: {1} -> None', field, value)
|
||||||
tags[field] = None
|
tags[field] = None
|
||||||
|
if self.config['update_database']:
|
||||||
|
item[field] = None
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ New features:
|
||||||
:bug:`1104` :bug:`1493`
|
:bug:`1104` :bug:`1493`
|
||||||
* :doc:`/plugins/plexupdate`: A new ``token`` configuration option lets you
|
* :doc:`/plugins/plexupdate`: A new ``token`` configuration option lets you
|
||||||
specify a key for Plex Home setups. Thanks to :user:`edcarroll`. :bug:`1494`
|
specify a key for Plex Home setups. Thanks to :user:`edcarroll`. :bug:`1494`
|
||||||
|
* :doc:`/plugins/zero`: A new ``update_database`` configuration option
|
||||||
|
allows the database to be updated along with files' tags. :bug:`1516`
|
||||||
|
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ Zero Plugin
|
||||||
|
|
||||||
The ``zero`` plugin allows you to null fields in files' metadata tags. Fields
|
The ``zero`` plugin allows you to null fields in files' metadata tags. Fields
|
||||||
can be nulled unconditionally or conditioned on a pattern match. For example,
|
can be nulled unconditionally or conditioned on a pattern match. For example,
|
||||||
the plugin can strip useless comments like "ripped by MyGreatRipper." This
|
the plugin can strip useless comments like "ripped by MyGreatRipper."
|
||||||
plugin only affects files' tags ; the beets database is left unchanged.
|
|
||||||
|
|
||||||
To use the ``zero`` plugin, enable the plugin in your configuration
|
To use the ``zero`` plugin, enable the plugin in your configuration
|
||||||
(see :ref:`using-plugins`).
|
(see :ref:`using-plugins`).
|
||||||
|
|
@ -21,6 +20,8 @@ fields to nullify and the conditions for nullifying them:
|
||||||
embedded in the media file.
|
embedded in the media file.
|
||||||
* To conditionally filter a field, use ``field: [regexp, regexp]`` to specify
|
* To conditionally filter a field, use ``field: [regexp, regexp]`` to specify
|
||||||
regular expressions.
|
regular expressions.
|
||||||
|
* 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.
|
||||||
|
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
|
|
@ -28,6 +29,7 @@ For example::
|
||||||
fields: month day genre comments
|
fields: month day genre comments
|
||||||
comments: [EAC, LAME, from.+collection, 'ripped by']
|
comments: [EAC, LAME, from.+collection, 'ripped by']
|
||||||
genre: [rnb, 'power metal']
|
genre: [rnb, 'power metal']
|
||||||
|
update_database: true
|
||||||
|
|
||||||
If a custom pattern is not defined for a given field, the field will be nulled
|
If a custom pattern is not defined for a given field, the field will be nulled
|
||||||
unconditionally.
|
unconditionally.
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,24 @@ class ZeroPluginTest(unittest.TestCase, TestHelper):
|
||||||
self.assertEqual(item['year'], 2000)
|
self.assertEqual(item['year'], 2000)
|
||||||
self.assertIsNone(mediafile.year)
|
self.assertIsNone(mediafile.year)
|
||||||
|
|
||||||
|
def test_change_database(self):
|
||||||
|
item = self.add_item_fixture(year=2000)
|
||||||
|
item.write()
|
||||||
|
mediafile = MediaFile(item.path)
|
||||||
|
self.assertEqual(2000, mediafile.year)
|
||||||
|
|
||||||
|
config['zero'] = {
|
||||||
|
'fields': ['year'],
|
||||||
|
'update_database': True,
|
||||||
|
}
|
||||||
|
self.load_plugins('zero')
|
||||||
|
|
||||||
|
item.write()
|
||||||
|
mediafile = MediaFile(item.path)
|
||||||
|
self.assertEqual(item['year'], 0)
|
||||||
|
self.assertIsNone(mediafile.year)
|
||||||
|
|
||||||
|
|
||||||
def test_album_art(self):
|
def test_album_art(self):
|
||||||
path = self.create_mediafile_fixture(images=['jpg'])
|
path = self.create_mediafile_fixture(images=['jpg'])
|
||||||
item = Item.from_path(path)
|
item = Item.from_path(path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue