Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mikf
GitHub Repository: mikf/gallery-dl
Path: blob/master/gallery_dl/postprocessor/actions.py
14119 views
1
# -*- coding: utf-8 -*-
2
3
# Copyright 2026 Mike Fährmann
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License version 2 as
7
# published by the Free Software Foundation.
8
9
"""Trigger actions"""
10
11
from .common import PostProcessor
12
from .. import actions
13
14
15
class ActionsPP(PostProcessor):
16
17
def __init__(self, job, options):
18
PostProcessor.__init__(self, job)
19
self.action = actions.parse(options.get("mode") or
20
options.get("action"))
21
self.args = {
22
"job" : job,
23
"log" : job.extractor.log,
24
"level": 0,
25
}
26
events = options.get("event")
27
if events is None:
28
events = ("prepare",)
29
elif isinstance(events, str):
30
events = events.split(",")
31
job.register_hooks({event: self.run for event in events}, options)
32
33
def run(self, pathfmt):
34
self.action({**pathfmt.kwdict, **self.args})
35
36
37
__postprocessor__ = ActionsPP
38
39