fix: ignore configured write types the plugin cannot handle
This commit is contained in:
parent
53b495249b
commit
991e499fad
3 changed files with 11 additions and 7 deletions
|
|
@ -150,4 +150,4 @@ types = [".mp3", ".flac"]
|
|||
tags = "genre"
|
||||
```
|
||||
|
||||
`plugins` limits which plugins run (`hash//` is listed as `hashdoubleslash`), `types` overrides the file types a plugin handles, and `id3.map` additionally reads an audio tag (here `GENRE`) into a category.
|
||||
`plugins` limits which plugins run (`hash//` is listed as `hashdoubleslash`), `types` overrides the file types a plugin handles (`write` ignores types the plugin does not support), and `id3.map` additionally reads an audio tag (here `GENRE`) into a category.
|
||||
|
|
|
|||
|
|
@ -695,12 +695,8 @@ class OrvaniTag:
|
|||
suffixes = plugin.TYPES # Load the plugin's defaults
|
||||
if plugin_name in config: # Check for local folder config overrides
|
||||
if 'types' in config[plugin_name]:
|
||||
suffixes = config[plugin_name]['types']
|
||||
for suffix in suffixes:
|
||||
if not suffix in plugin.TYPES:
|
||||
suffixes.remove(suffix)
|
||||
if not suffixes:
|
||||
suffixes = plugin.TYPES
|
||||
# Only types the plugin can write, falling back to its defaults
|
||||
suffixes = [suffix for suffix in config[plugin_name]['types'] if suffix in plugin.TYPES] or plugin.TYPES
|
||||
|
||||
o.file = Path(filename)
|
||||
if o.file.suffix in suffixes:
|
||||
|
|
|
|||
|
|
@ -143,3 +143,11 @@ def test_cmd_scan_defaults_to_current_folder(cwd, monkeypatch):
|
|||
monkeypatch.setattr(sys, 'argv', ['otag', 's'])
|
||||
main()
|
||||
assert (cwd / 'sub' / orvani.CONTEXT_FILE).read_text() == 'doc.pdf --- #lofi\n'
|
||||
|
||||
|
||||
def test_write_ignores_configured_types_the_plugin_cannot_handle(cwd):
|
||||
(cwd / orvani.CONFIG_FILE).write_text('[pdf]\ntypes = [".xyz", ".abc", ".pdf"]\n')
|
||||
(cwd / 'doc.abc').write_text('not a pdf')
|
||||
OrvaniTag().add('doc.abc', '#lofi')
|
||||
assert OrvaniTag().write_metadata('doc.abc', 'pdf') == [4, ['.pdf'], 'pdf', True]
|
||||
assert (cwd / 'doc.abc').read_text() == 'not a pdf'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue