1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 12:25:03 -04:00

Make outtmpl more robust and catch errors early

This commit is contained in:
pukkandan
2021-06-08 20:11:00 +05:30
parent 324ad82006
commit 76a264ac9e
3 changed files with 45 additions and 4 deletions

View File

@@ -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'