mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[postprocessor:metadata] assume 'mode: custom' when format is set
{"name": "metadata", "format": "foobar"} will now implicitly use mode:custom and no longer mode:json like before
This commit is contained in:
parent
f0321f423d
commit
b57015cf0a
@ -20,14 +20,8 @@ class MetadataPP(PostProcessor):
|
||||
PostProcessor.__init__(self, job)
|
||||
|
||||
mode = options.get("mode", "json")
|
||||
if mode == "custom":
|
||||
self.write = self._write_custom
|
||||
cfmt = options.get("content-format") or options.get("format")
|
||||
if isinstance(cfmt, list):
|
||||
cfmt = "\n".join(cfmt) + "\n"
|
||||
self._content_fmt = formatter.parse(cfmt).format_map
|
||||
ext = "txt"
|
||||
elif mode == "tags":
|
||||
cfmt = options.get("content-format") or options.get("format")
|
||||
if mode == "tags":
|
||||
self.write = self._write_tags
|
||||
ext = "txt"
|
||||
elif mode == "modify":
|
||||
@ -41,6 +35,12 @@ class MetadataPP(PostProcessor):
|
||||
self.run = self._run_delete
|
||||
self.fields = options.get("fields")
|
||||
ext = None
|
||||
elif mode == "custom" or cfmt:
|
||||
self.write = self._write_custom
|
||||
if isinstance(cfmt, list):
|
||||
cfmt = "\n".join(cfmt) + "\n"
|
||||
self._content_fmt = formatter.parse(cfmt).format_map
|
||||
ext = "txt"
|
||||
else:
|
||||
self.write = self._write_json
|
||||
self.indent = options.get("indent", 4)
|
||||
|
@ -267,6 +267,7 @@ class MetadataTest(BasePostprocessorTest):
|
||||
test({"mode": "custom", "content-format": "{foo}\n{missing}\n"})
|
||||
test({"mode": "custom", "content-format": ["{foo}", "{missing}"]})
|
||||
test({"mode": "custom", "format": "{foo}\n{missing}\n"})
|
||||
test({"format": "{foo}\n{missing}\n"})
|
||||
|
||||
def test_metadata_extfmt(self):
|
||||
pp = self._create({
|
||||
|
Loading…
Reference in New Issue
Block a user