From 2b38f7b2bcb327b376c896211cd727690dbe5aa1 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 11 Mar 2022 14:28:27 +0530 Subject: [PATCH] [MetadataParser] Validate outtmpl early --- yt_dlp/postprocessor/metadataparser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yt_dlp/postprocessor/metadataparser.py b/yt_dlp/postprocessor/metadataparser.py index 5452b92d8..5bc435da3 100644 --- a/yt_dlp/postprocessor/metadataparser.py +++ b/yt_dlp/postprocessor/metadataparser.py @@ -1,5 +1,4 @@ import re - from enum import Enum from .common import PostProcessor @@ -26,12 +25,17 @@ def validate_action(cls, action, *data): ''' if not isinstance(action, cls.Actions): raise ValueError(f'{action!r} is not a valid action') - getattr(cls, action.value)(cls, *data) + getattr(cls, action.value)(cls, *data) # So this can raise error to validate @staticmethod def field_to_template(tmpl): if re.match(r'[a-zA-Z_]+$', tmpl): return f'%({tmpl})s' + + from ..YoutubeDL import YoutubeDL + err = YoutubeDL.validate_outtmpl(tmpl) + if err: + raise err return tmpl @staticmethod