aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-04-30 16:45:21 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-04-30 16:45:21 -0400
commit33d4eae5a6df8aaf6757f52ae25f514ff1211c62 (patch)
tree7ad425b022dcc1daea1c84c720a266f0134db705 /gallery_dl/postprocessor
parentf98ab7aaca3c4acbd5a793267791749740330e9c (diff)
New upstream version 1.25.3.upstream/1.25.3
Diffstat (limited to 'gallery_dl/postprocessor')
-rw-r--r--gallery_dl/postprocessor/metadata.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/gallery_dl/postprocessor/metadata.py b/gallery_dl/postprocessor/metadata.py
index 714f4fe..5004bed 100644
--- a/gallery_dl/postprocessor/metadata.py
+++ b/gallery_dl/postprocessor/metadata.py
@@ -124,10 +124,8 @@ class MetadataPP(PostProcessor):
for key, func in self.fields.items():
obj = kwdict
try:
- while "[" in key:
- name, _, key = key.partition("[")
- obj = obj[name]
- key = key.rstrip("]")
+ if "[" in key:
+ obj, key = _traverse(obj, key)
obj[key] = func(kwdict)
except Exception:
pass
@@ -137,10 +135,8 @@ class MetadataPP(PostProcessor):
for key in self.fields:
obj = kwdict
try:
- while "[" in key:
- name, _, key = key.partition("[")
- obj = obj[name]
- key = key.rstrip("]")
+ if "[" in key:
+ obj, key = _traverse(obj, key)
del obj[key]
except Exception:
pass
@@ -214,4 +210,15 @@ class MetadataPP(PostProcessor):
)
+def _traverse(obj, key):
+ name, _, key = key.partition("[")
+ obj = obj[name]
+
+ while "[" in key:
+ name, _, key = key.partition("[")
+ obj = obj[name.strip("\"']")]
+
+ return obj, key.strip("\"']")
+
+
__postprocessor__ = MetadataPP