From 0ad7b5546bd0b55d683613cb22e01d60a8868477 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Tue, 29 Dec 2015 14:44:31 +0000 Subject: [PATCH] Allow "." as a separator for msecs when parsing SRT timestamp --- srt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srt.py b/srt.py index bcfd2bc..c995f82 100755 --- a/srt.py +++ b/srt.py @@ -142,7 +142,9 @@ def srt_timestamp_to_timedelta(srt_timestamp): >>> srt.srt_timestamp_to_timedelta('01:23:04,000') datetime.timedelta(0, 4984) ''' - hrs, mins, secs, msecs = (int(x) for x in re.split('[,:]', srt_timestamp)) + # "." is not technically a legal separator, but some subtitle editors use + # it to delimit msecs, and some players accept it. + hrs, mins, secs, msecs = (int(x) for x in re.split('[,:.]', srt_timestamp)) return timedelta(hours=hrs, minutes=mins, seconds=secs, milliseconds=msecs)