From 8ab8f81f4e8571859799f214b52a3a24ee0256f4 Mon Sep 17 00:00:00 2001 From: Nathan Gilbert Date: Mon, 6 Jun 2022 15:24:11 -0600 Subject: [PATCH 1/2] Match MS Teams timestamp format --- webvtt/parsers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webvtt/parsers.py b/webvtt/parsers.py index 3a978ca..bf47de1 100644 --- a/webvtt/parsers.py +++ b/webvtt/parsers.py @@ -155,7 +155,10 @@ class WebVTTParser(TextBasedParser): WebVTT parser. """ - TIMEFRAME_LINE_PATTERN = re.compile(r'\s*((?:\d+:)?\d{2}:\d{2}.\d{3})\s*-->\s*((?:\d+:)?\d{2}:\d{2}.\d{3})') + TIMEFRAME_LINE_PATTERN = re.compile( + # matches timestamp format: 0:0:13.540 --> 0:0:17.850 + r'\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{1,3})\s*-->\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{1,3})' + ) COMMENT_PATTERN = re.compile(r'NOTE(?:\s.+|$)') STYLE_PATTERN = re.compile(r'STYLE[ \t]*$') From 90bea0b8a67d6f3d52cd3bfd9880b349516fa894 Mon Sep 17 00:00:00 2001 From: Nathan Gilbert Date: Mon, 6 Jun 2022 15:33:19 -0600 Subject: [PATCH 2/2] remove the 1 to 3 for seconds --- webvtt/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webvtt/parsers.py b/webvtt/parsers.py index bf47de1..2676c3a 100644 --- a/webvtt/parsers.py +++ b/webvtt/parsers.py @@ -157,7 +157,7 @@ class WebVTTParser(TextBasedParser): TIMEFRAME_LINE_PATTERN = re.compile( # matches timestamp format: 0:0:13.540 --> 0:0:17.850 - r'\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{1,3})\s*-->\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{1,3})' + r'\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{3})\s*-->\s*((?:\d+:)?\d{1,2}:\d{1,2}.\d{3})' ) COMMENT_PATTERN = re.compile(r'NOTE(?:\s.+|$)') STYLE_PATTERN = re.compile(r'STYLE[ \t]*$')