1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2026-01-07 23:41:35 +00:00

Add more post-processing stages

playlist = After entire playlist
after_video = After downloading all formats of a video
This commit is contained in:
pukkandan
2022-01-02 16:23:20 +05:30
parent 1e43a6f733
commit ebed8b3732
5 changed files with 23 additions and 9 deletions

View File

@@ -1766,6 +1766,10 @@ class YoutubeDL(object):
for tmpl in self.params['forceprint'].get('playlist', []):
self._forceprint(tmpl, ie_result)
for pp in self._pps['playlist']:
ie_result = self.run_pp(pp, ie_result)
self.to_screen('[download] Finished downloading playlist: %s' % playlist)
return ie_result
@@ -2564,6 +2568,10 @@ class YoutubeDL(object):
new_info['__original_infodict'] = info_dict
new_info.update(fmt)
self.process_info(new_info)
for pp in self._pps['after_video']:
info_dict = self.run_pp(pp, info_dict)
# We update the info dict with the selected best quality format (backwards compatibility)
if formats_to_download:
info_dict.update(formats_to_download[-1])

View File

@@ -1482,8 +1482,10 @@ def parseOpts(overrideArguments=None):
'ARGS are a semicolon ";" delimited list of NAME=VALUE. '
'The "when" argument determines when the postprocessor is invoked. '
'It can be one of "pre_process" (after extraction), '
'"before_dl" (before video download), "post_process" (after video download; default) '
'or "after_move" (after moving file to their final locations). '
'"before_dl" (before video download), "post_process" (after video download; default), '
'"after_move" (after moving file to their final locations), '
'"after_video" (after downloading and processing all formats of a video), '
'or "playlist" (end of playlist). '
'This option can be used multiple times to add different postprocessors'))
sponsorblock = optparse.OptionGroup(parser, 'SponsorBlock Options', description=(

View File

@@ -3036,7 +3036,7 @@ def qualities(quality_ids):
return q
POSTPROCESS_WHEN = {'pre_process', 'before_dl', 'after_move', 'post_process'}
POSTPROCESS_WHEN = {'pre_process', 'before_dl', 'after_move', 'post_process', 'after_video', 'playlist'}
DEFAULT_OUTTMPL = {