[postprocessor] add 'post-after' event (#3117)
This commit is contained in:
@@ -3653,6 +3653,8 @@ Description
|
|||||||
``post``
|
``post``
|
||||||
When starting to download all files of a `post`,
|
When starting to download all files of a `post`,
|
||||||
e.g. a Tweet on Twitter or a post on Patreon.
|
e.g. a Tweet on Twitter or a post on Patreon.
|
||||||
|
``post-after``
|
||||||
|
After downloading all files of a `post`
|
||||||
|
|
||||||
|
|
||||||
metadata.fields
|
metadata.fields
|
||||||
|
|||||||
@@ -283,6 +283,9 @@ class DownloadJob(Job):
|
|||||||
if not self.pathfmt:
|
if not self.pathfmt:
|
||||||
self.initialize(kwdict)
|
self.initialize(kwdict)
|
||||||
else:
|
else:
|
||||||
|
if "post-after" in self.hooks:
|
||||||
|
for callback in self.hooks["post-after"]:
|
||||||
|
callback(self.pathfmt)
|
||||||
self.pathfmt.set_directory(kwdict)
|
self.pathfmt.set_directory(kwdict)
|
||||||
if "post" in self.hooks:
|
if "post" in self.hooks:
|
||||||
for callback in self.hooks["post"]:
|
for callback in self.hooks["post"]:
|
||||||
@@ -337,14 +340,20 @@ class DownloadJob(Job):
|
|||||||
self._write_unsupported(url)
|
self._write_unsupported(url)
|
||||||
|
|
||||||
def handle_finalize(self):
|
def handle_finalize(self):
|
||||||
pathfmt = self.pathfmt
|
|
||||||
if self.archive:
|
if self.archive:
|
||||||
self.archive.close()
|
self.archive.close()
|
||||||
|
|
||||||
|
pathfmt = self.pathfmt
|
||||||
if pathfmt:
|
if pathfmt:
|
||||||
|
hooks = self.hooks
|
||||||
|
if "post-after" in hooks:
|
||||||
|
for callback in hooks["post-after"]:
|
||||||
|
callback(pathfmt)
|
||||||
|
|
||||||
self.extractor._store_cookies()
|
self.extractor._store_cookies()
|
||||||
if "finalize" in self.hooks:
|
if "finalize" in hooks:
|
||||||
status = self.status
|
status = self.status
|
||||||
for callback in self.hooks["finalize"]:
|
for callback in hooks["finalize"]:
|
||||||
callback(pathfmt, status)
|
callback(pathfmt, status)
|
||||||
|
|
||||||
def handle_skip(self):
|
def handle_skip(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user