diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-08 20:11:00 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-08 20:11:00 +0530 |
commit | 76a264ac9e7675bf67be844b9a9d0288ac7427a9 (patch) | |
tree | d6386564eb1c39ff250598ded0be83a16ee2a26c /yt_dlp/__init__.py | |
parent | 324ad82006748ebfe4b3fa8f67f160eb000ee6eb (diff) |
Make outtmpl more robust and catch errors early
Diffstat (limited to 'yt_dlp/__init__.py')
-rw-r--r-- | yt_dlp/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 45a29d3c7..6d6b0dd66 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -24,6 +24,7 @@ from .utils import ( DateRange, decodeOption, DownloadError, + error_to_compat_str, ExistingVideoReached, expand_path, match_filter_func, @@ -307,6 +308,16 @@ def _real_main(argv=None): else: _unused_compat_opt('filename') + def validate_outtmpl(tmpl, msg): + err = YoutubeDL.validate_outtmpl(tmpl) + if err: + parser.error('invalid %s %r: %s' % (msg, tmpl, error_to_compat_str(err))) + + for k, tmpl in opts.outtmpl.items(): + validate_outtmpl(tmpl, '%s output template' % k) + for tmpl in opts.forceprint: + validate_outtmpl(tmpl, 'print template') + if opts.extractaudio and not opts.keepvideo and opts.format is None: opts.format = 'bestaudio/best' |