Fix PostProcessor hooks not registered for some PPs

Closes #1993
This commit is contained in:
pukkandan 2021-12-14 21:08:24 +05:30
parent 19188702ef
commit 5bfc8bee5a
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

View File

@ -634,13 +634,6 @@ class YoutubeDL(object):
self.print_debug_header() self.print_debug_header()
self.add_default_info_extractors() self.add_default_info_extractors()
for pp_def_raw in self.params.get('postprocessors', []):
pp_def = dict(pp_def_raw)
when = pp_def.pop('when', 'post_process')
pp_class = get_postprocessor(pp_def.pop('key'))
pp = pp_class(self, **compat_kwargs(pp_def))
self.add_post_processor(pp, when=when)
hooks = { hooks = {
'post_hooks': self.add_post_hook, 'post_hooks': self.add_post_hook,
'progress_hooks': self.add_progress_hook, 'progress_hooks': self.add_progress_hook,
@ -650,6 +643,13 @@ class YoutubeDL(object):
for ph in self.params.get(opt, []): for ph in self.params.get(opt, []):
fn(ph) fn(ph)
for pp_def_raw in self.params.get('postprocessors', []):
pp_def = dict(pp_def_raw)
when = pp_def.pop('when', 'post_process')
self.add_post_processor(
get_postprocessor(pp_def.pop('key'))(self, **compat_kwargs(pp_def)),
when=when)
register_socks_protocols() register_socks_protocols()
def preload_download_archive(fn): def preload_download_archive(fn):
@ -736,6 +736,9 @@ class YoutubeDL(object):
def add_postprocessor_hook(self, ph): def add_postprocessor_hook(self, ph):
"""Add the postprocessing progress hook""" """Add the postprocessing progress hook"""
self._postprocessor_hooks.append(ph) self._postprocessor_hooks.append(ph)
for pps in self._pps.values():
for pp in pps:
pp.add_progress_hook(ph)
def _bidi_workaround(self, message): def _bidi_workaround(self, message):
if not hasattr(self, '_output_channel'): if not hasattr(self, '_output_channel'):