diff options
| author | 2025-09-23 07:44:44 -0400 | |
|---|---|---|
| committer | 2025-09-23 07:44:44 -0400 | |
| commit | 291c04af647559317fc9f9f392ad43841ec509ad (patch) | |
| tree | 13a72906223927180001b362d086c82401cb7843 /gallery_dl/postprocessor/python.py | |
| parent | 065386e00c7a6c8bbe4bb23a545a7fc7b2c09a4a (diff) | |
| parent | 42b62671fabfdcf983a9575221420d85f7fbcac1 (diff) | |
Update upstream source from tag 'upstream/1.30.8'
Update to upstream version '1.30.8'
with Debian dir 51367313d3355f7d0d16a754c5c63135fb3c72e2
Diffstat (limited to 'gallery_dl/postprocessor/python.py')
| -rw-r--r-- | gallery_dl/postprocessor/python.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/gallery_dl/postprocessor/python.py b/gallery_dl/postprocessor/python.py index db71da2..66d9343 100644 --- a/gallery_dl/postprocessor/python.py +++ b/gallery_dl/postprocessor/python.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2023 Mike Fährmann +# Copyright 2023-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -17,13 +17,14 @@ class PythonPP(PostProcessor): def __init__(self, job, options): PostProcessor.__init__(self, job) - spec = options["function"] - module_name, _, function_name = spec.rpartition(":") - module = util.import_file(module_name) - self.function = getattr(module, function_name) - - if self._init_archive(job, options): - self.run = self.run_archive + mode = options.get("mode") + if mode == "eval" or not mode and options.get("expression"): + self.function = util.compile_expression(options["expression"]) + else: + spec = options["function"] + module_name, _, function_name = spec.rpartition(":") + module = util.import_file(module_name) + self.function = getattr(module, function_name) events = options.get("event") if events is None: @@ -32,6 +33,9 @@ class PythonPP(PostProcessor): events = events.split(",") job.register_hooks({event: self.run for event in events}, options) + if self._init_archive(job, options): + self.run = self.run_archive + def run(self, pathfmt): self.function(pathfmt.kwdict) |
