mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
parent
8d9b902243
commit
5520aa2dc9
4 changed files with 15 additions and 1 deletions
|
@ -773,6 +773,8 @@ ## Post-Processing Options:
|
||||||
downloaded file is also available. If no
|
downloaded file is also available. If no
|
||||||
fields are passed, "%(filepath)s" is
|
fields are passed, "%(filepath)s" is
|
||||||
appended to the end of the command
|
appended to the end of the command
|
||||||
|
--exec-before-download CMD Execute a command before the actual
|
||||||
|
download. The syntax is the same as --exec
|
||||||
--convert-subs FORMAT Convert the subtitles to another format
|
--convert-subs FORMAT Convert the subtitles to another format
|
||||||
(currently supported: srt|vtt|ass|lrc)
|
(currently supported: srt|vtt|ass|lrc)
|
||||||
(Alias: --convert-subtitles)
|
(Alias: --convert-subtitles)
|
||||||
|
|
|
@ -415,6 +415,13 @@ def report_conflict(arg1, arg2):
|
||||||
# Run this before the actual video download
|
# Run this before the actual video download
|
||||||
'when': 'before_dl'
|
'when': 'before_dl'
|
||||||
})
|
})
|
||||||
|
# Must be after all other before_dl
|
||||||
|
if opts.exec_before_dl_cmd:
|
||||||
|
postprocessors.append({
|
||||||
|
'key': 'ExecAfterDownload',
|
||||||
|
'exec_cmd': opts.exec_before_dl_cmd,
|
||||||
|
'when': 'before_dl'
|
||||||
|
})
|
||||||
if opts.extractaudio:
|
if opts.extractaudio:
|
||||||
postprocessors.append({
|
postprocessors.append({
|
||||||
'key': 'FFmpegExtractAudio',
|
'key': 'FFmpegExtractAudio',
|
||||||
|
|
|
@ -1265,6 +1265,10 @@ def _dict_from_options_callback(
|
||||||
'Similar syntax to the output template can be used to pass any field as arguments to the command. '
|
'Similar syntax to the output template can be used to pass any field as arguments to the command. '
|
||||||
'An additional field "filepath" that contains the final path of the downloaded file is also available. '
|
'An additional field "filepath" that contains the final path of the downloaded file is also available. '
|
||||||
'If no fields are passed, "%(filepath)s" is appended to the end of the command'))
|
'If no fields are passed, "%(filepath)s" is appended to the end of the command'))
|
||||||
|
postproc.add_option(
|
||||||
|
'--exec-before-download',
|
||||||
|
metavar='CMD', dest='exec_before_dl_cmd',
|
||||||
|
help='Execute a command before the actual download. The syntax is the same as --exec')
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--convert-subs', '--convert-sub', '--convert-subtitles',
|
'--convert-subs', '--convert-sub', '--convert-subtitles',
|
||||||
metavar='FORMAT', dest='convertsubtitles', default=None,
|
metavar='FORMAT', dest='convertsubtitles', default=None,
|
||||||
|
|
|
@ -28,7 +28,8 @@ def parse_cmd(self, cmd, info):
|
||||||
# If no replacements are found, replace {} for backard compatibility
|
# If no replacements are found, replace {} for backard compatibility
|
||||||
if '{}' not in cmd:
|
if '{}' not in cmd:
|
||||||
cmd += ' {}'
|
cmd += ' {}'
|
||||||
return cmd.replace('{}', compat_shlex_quote(info['filepath']))
|
return cmd.replace('{}', compat_shlex_quote(
|
||||||
|
info.get('filepath') or info['_filename']))
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
cmd = self.parse_cmd(self.exec_cmd, info)
|
cmd = self.parse_cmd(self.exec_cmd, info)
|
||||||
|
|
Loading…
Reference in a new issue