From db2fe38b5508cbd28b89893219d9cccd41406851 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sat, 19 Dec 2015 19:29:51 +0800 Subject: [PATCH] [utils] Support alternative timestamp format in TTML Fixes #7608 --- test/test_utils.py | 1 + youtube_dl/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 86045e680..e4e8d3825 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -667,6 +667,7 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') self.assertEqual(parse_dfxp_time_expr('0.1s'), 0.1) self.assertEqual(parse_dfxp_time_expr('00:00:01'), 1.0) self.assertEqual(parse_dfxp_time_expr('00:00:01.100'), 1.1) + self.assertEqual(parse_dfxp_time_expr('00:00:01:100'), 1.1) def test_dfxp2srt(self): dfxp_data = ''' diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index ee20c3d9b..5b396ede8 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1982,9 +1982,9 @@ def parse_dfxp_time_expr(time_expr): if mobj: return float(mobj.group('time_offset')) - mobj = re.match(r'^(\d+):(\d\d):(\d\d(?:\.\d+)?)$', time_expr) + mobj = re.match(r'^(\d+):(\d\d):(\d\d(?:(?:\.|:)\d+)?)$', time_expr) if mobj: - return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3)) + return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3).replace(':', '.')) def srt_subtitles_timecode(seconds): -- 2.22.2