diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py index 03294b483f..5004bed6de 100644 --- a/gallery_dl/postprocessor/metadata.py +++ b/gallery_dl/postprocessor/metadata.py @@ -216,9 +216,9 @@ def _traverse(obj, key): while "[" in key: name, _, key = key.partition("[") - obj = obj[name.rstrip("]")] + obj = obj[name.strip("\"']")] - return obj, key.strip("]") + return obj, key.strip("\"']") __postprocessor__ = MetadataPP diff --git a/test/test_postprocessor.py b/test/test_postprocessor.py index 543947b8c6..1630e8a3a5 100644 --- a/test/test_postprocessor.py +++ b/test/test_postprocessor.py @@ -392,11 +392,11 @@ def test_metadata_modify(self): self._create({ "mode": "modify", "fields": { - "foo" : "{filename}-{foo!s}", - "foo2" : "\fE bar['bax'] + 122", - "bar[baz]" : "{_now}", - "bar[ba2]" : "\fE {}", - "bar[ba2][a]": "test", + "foo" : "{filename}-{foo!s}", + "foo2" : "\fE bar['bax'] + 122", + "bar['baz']" : "{_now}", + "bar[\"ba2\"]" : "\fE {}", + "bar['ba2'][a]": "test", }, }, kwdict) @@ -423,7 +423,7 @@ def test_metadata_delete(self): } self._create({ "mode": "delete", - "fields": ["foo", "bar[bax]", "bar[baz][a]"], + "fields": ["foo", "bar['bax']", "bar[\"baz\"][a]"], }, kwdict) pdict = self.pathfmt.kwdict