]> jfr.im git - yt-dlp.git/commitdiff
[webvtt] Allow spaces before newlines for CueBlock (#7681)
authorTSRBerry <redacted>
Tue, 28 Nov 2023 23:20:06 +0000 (00:20 +0100)
committerGitHub <redacted>
Tue, 28 Nov 2023 23:20:06 +0000 (04:50 +0530)
Closes #7453

Ref: https://www.w3.org/TR/webvtt1/#webvtt-cue-block

yt_dlp/webvtt.py

index dd72982778c275688398644794f303f538ea332a..596e9bf738ae3be388ee4506cacc6f7b0183843c 100644 (file)
@@ -95,6 +95,7 @@ def __init__(self, parser):
 _REGEX_EOF = re.compile(r'\Z')
 _REGEX_NL = re.compile(r'(?:\r\n|[\r\n]|$)')
 _REGEX_BLANK = re.compile(r'(?:\r\n|[\r\n])+')
+_REGEX_OPTIONAL_WHITESPACE = re.compile(r'[ \t]*')
 
 
 def _parse_ts(ts):
@@ -285,6 +286,7 @@ def parse(cls, parser):
         m1 = parser.consume(_REGEX_TS)
         if not m1:
             return None
+        parser.consume(_REGEX_OPTIONAL_WHITESPACE)
         m2 = parser.consume(cls._REGEX_SETTINGS)
         if not parser.consume(_REGEX_NL):
             return None