[pp] add 'child' & 'child-after' events

This commit is contained in:
Mike Fährmann
2026-02-01 21:16:31 +01:00
parent 56dcd00391
commit c42a5dce5c
3 changed files with 18 additions and 1 deletions

View File

@@ -431,6 +431,12 @@ class DownloadJob(Job):
return
self.visited.add(url)
if "child" in self.hooks:
pathfmt = self.pathfmt
pathfmt.kwdict = kwdict
for callback in self.hooks["child"]:
callback(pathfmt)
if cls := kwdict.get("_extractor"):
extr = cls.from_url(url)
else:
@@ -502,6 +508,12 @@ class DownloadJob(Job):
else:
self._write_unsupported(url)
if "child-after" in self.hooks:
pathfmt = self.pathfmt
pathfmt.kwdict = kwdict
for callback in self.hooks["child-after"]:
callback(pathfmt)
def handle_finalize(self):
if self.archive:
if not self.status:

View File

@@ -179,7 +179,8 @@ class PrintAction(argparse.Action):
event = event.strip().lower()
if event not in {"init", "file", "after", "skip", "error",
"prepare", "prepare-after", "post", "post-after",
"finalize", "finalize-success", "finalize-error"}:
"finalize", "finalize-success", "finalize-error",
"child", "child-after"}:
format_string = value
event = ("prepare",)