mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 18:32:39 +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:
parent
1e43a6f733
commit
ebed8b3732
10
README.md
10
README.md
@ -948,10 +948,12 @@ ## Post-Processing Options:
|
|||||||
"pre_process" (after extraction),
|
"pre_process" (after extraction),
|
||||||
"before_dl" (before video download),
|
"before_dl" (before video download),
|
||||||
"post_process" (after video download;
|
"post_process" (after video download;
|
||||||
default) or "after_move" (after moving file
|
default), "after_move" (after moving file
|
||||||
to their final locations). This option can
|
to their final locations), "after_video"
|
||||||
be used multiple times to add different
|
(after downloading and processing all
|
||||||
postprocessors
|
formats of a video), or "playlist" (end of
|
||||||
|
playlist). This option can be used multiple
|
||||||
|
times to add different postprocessors
|
||||||
|
|
||||||
## SponsorBlock Options:
|
## SponsorBlock Options:
|
||||||
Make chapter entries for, or remove various segments (sponsor,
|
Make chapter entries for, or remove various segments (sponsor,
|
||||||
|
@ -1766,6 +1766,10 @@ def get_entry(i):
|
|||||||
|
|
||||||
for tmpl in self.params['forceprint'].get('playlist', []):
|
for tmpl in self.params['forceprint'].get('playlist', []):
|
||||||
self._forceprint(tmpl, ie_result)
|
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)
|
self.to_screen('[download] Finished downloading playlist: %s' % playlist)
|
||||||
return ie_result
|
return ie_result
|
||||||
|
|
||||||
@ -2564,6 +2568,10 @@ def is_wellformed(f):
|
|||||||
new_info['__original_infodict'] = info_dict
|
new_info['__original_infodict'] = info_dict
|
||||||
new_info.update(fmt)
|
new_info.update(fmt)
|
||||||
self.process_info(new_info)
|
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)
|
# We update the info dict with the selected best quality format (backwards compatibility)
|
||||||
if formats_to_download:
|
if formats_to_download:
|
||||||
info_dict.update(formats_to_download[-1])
|
info_dict.update(formats_to_download[-1])
|
||||||
|
@ -1482,8 +1482,10 @@ def _dict_from_options_callback(
|
|||||||
'ARGS are a semicolon ";" delimited list of NAME=VALUE. '
|
'ARGS are a semicolon ";" delimited list of NAME=VALUE. '
|
||||||
'The "when" argument determines when the postprocessor is invoked. '
|
'The "when" argument determines when the postprocessor is invoked. '
|
||||||
'It can be one of "pre_process" (after extraction), '
|
'It can be one of "pre_process" (after extraction), '
|
||||||
'"before_dl" (before video download), "post_process" (after video download; default) '
|
'"before_dl" (before video download), "post_process" (after video download; default), '
|
||||||
'or "after_move" (after moving file to their final locations). '
|
'"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'))
|
'This option can be used multiple times to add different postprocessors'))
|
||||||
|
|
||||||
sponsorblock = optparse.OptionGroup(parser, 'SponsorBlock Options', description=(
|
sponsorblock = optparse.OptionGroup(parser, 'SponsorBlock Options', description=(
|
||||||
|
@ -3036,7 +3036,7 @@ def q(qid):
|
|||||||
return q
|
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 = {
|
DEFAULT_OUTTMPL = {
|
||||||
|
@ -14,8 +14,10 @@ def __init__(self, downloader=None, **kwargs):
|
|||||||
|
|
||||||
# ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run
|
# ℹ️ See docstring of yt_dlp.postprocessor.common.PostProcessor.run
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
|
if info.get('_type', 'video') != 'video': # PP was called for playlist
|
||||||
|
self.to_screen(f'Post-processing playlist {info.get("id")!r} with {self._kwargs}')
|
||||||
|
elif info.get('filepath'): # PP was called after download (default)
|
||||||
filepath = info.get('filepath')
|
filepath = info.get('filepath')
|
||||||
if filepath: # PP was called after download (default)
|
|
||||||
self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}')
|
self.to_screen(f'Post-processed {filepath!r} with {self._kwargs}')
|
||||||
else: # PP was called before actual download
|
else: # PP was called before actual download
|
||||||
filepath = info.get('_filename')
|
filepath = info.get('_filename')
|
||||||
|
Loading…
Reference in New Issue
Block a user