diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-03 16:43:54 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-03 19:40:02 +0530 |
commit | 1e43a6f7336f4d9691dc52a1bc7cfe14ba7a936d (patch) | |
tree | 218655a09fd54a9c51f4db1d5bb7564c633b6f3e /yt_dlp/__init__.py | |
parent | ca30f449a187addcdb99f4c39333e7a292756597 (diff) |
Allow `--exec` to be run at any post-processing stage
Deprecates `--exec-before-download`
Diffstat (limited to 'yt_dlp/__init__.py')
-rw-r--r-- | yt_dlp/__init__.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index af7a4e195..85f000df4 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -143,6 +143,8 @@ def _real_main(argv=None): '"-f best" selects the best pre-merged format which is often not the best option', 'To let yt-dlp download and merge the best available formats, simply do not pass any format selection', 'If you know what you are doing and want only the best pre-merged format, use "-f b" instead to suppress this warning'))) + if opts.exec_cmd.get('before_dl') and opts.exec_before_dl_cmd: + parser.error('using "--exec-before-download" conflicts with "--exec before_dl:"') if opts.usenetrc and (opts.username is not None or opts.password is not None): parser.error('using .netrc conflicts with giving username/password') if opts.password is not None and opts.username is None: @@ -489,13 +491,6 @@ def _real_main(argv=None): # Run this before the actual video download 'when': 'before_dl' }) - # Must be after all other before_dl - if opts.exec_before_dl_cmd: - postprocessors.append({ - 'key': 'Exec', - 'exec_cmd': opts.exec_before_dl_cmd, - 'when': 'before_dl' - }) if opts.extractaudio: postprocessors.append({ 'key': 'FFmpegExtractAudio', @@ -596,13 +591,15 @@ def _real_main(argv=None): # XAttrMetadataPP should be run after post-processors that may change file contents if opts.xattrs: postprocessors.append({'key': 'XAttrMetadata'}) - # Exec must be the last PP - if opts.exec_cmd: + # Exec must be the last PP of each category + if opts.exec_before_dl_cmd: + opts.exec_cmd.setdefault('before_dl', opts.exec_before_dl_cmd) + for when, exec_cmd in opts.exec_cmd.items(): postprocessors.append({ 'key': 'Exec', - 'exec_cmd': opts.exec_cmd, + 'exec_cmd': exec_cmd, # Run this only after the files have been moved to their final locations - 'when': 'after_move' + 'when': when, }) def report_args_compat(arg, name): |