Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mikf
GitHub Repository: mikf/gallery-dl
Path: blob/master/gallery_dl/postprocessor/directory.py
8753 views
1
# -*- coding: utf-8 -*-
2
3
# Copyright 2025 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 directory format string evaluation"""
10
11
from .common import PostProcessor
12
13
14
class DirectoryPP(PostProcessor):
15
16
def __init__(self, job, options):
17
PostProcessor.__init__(self, job)
18
19
events = options.get("event")
20
if events is None:
21
events = ("prepare",)
22
elif isinstance(events, str):
23
events = events.split(",")
24
job.register_hooks({event: self.run for event in events}, options)
25
26
def run(self, pathfmt):
27
pathfmt.set_directory(pathfmt.kwdict)
28
29
30
__postprocessor__ = DirectoryPP
31
32