Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/subtitles/teams_timeframe.vtt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
WEBVTT

0:0:0.0 --> 0:0:0.570
<v Yuri Bakulin>There you go.</v>

0:0:0.210 --> 0:0:1.130
<v Adrian Petrescu>Why hello there, Yuri.</v>
7 changes: 7 additions & 0 deletions tests/test_webvtt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ def test_webvtt_timestamps_format(self):
self.assertEqual(vtt.captions[2].start, '00:00:11.890')
self.assertEqual(vtt.captions[2].end, '00:00:16.320')

def test_webvtt_microsoft_teams_timestamps_format(self):
vtt = webvtt.read(self._get_file('teams_timeframe.vtt'))
self.assertEqual(vtt.captions[0].start, '00:00:00.000')
self.assertEqual(vtt.captions[0].end, '00:00:00.570')
self.assertEqual(vtt.captions[1].start, '00:00:00.210')
self.assertEqual(vtt.captions[1].end, '00:00:01.130')

def test_parse_timestamp(self):
caption = Caption(start='02:03:11.890')
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion webvtt/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ 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(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]*$')

Expand Down
2 changes: 1 addition & 1 deletion webvtt/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .errors import MalformedCaptionError

TIMESTAMP_PATTERN = re.compile('(\d+)?:?(\d{2}):(\d{2})[.,](\d{3})')
TIMESTAMP_PATTERN = re.compile('(\d+)?:?(\d{1,2}):(\d{1,2})[.,](\d{1,3})')

__all__ = ['Caption']

Expand Down