]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Support alternative timestamp format in TTML
authorYen Chi Hsuan <yan12125@gmail.com>
Sat, 19 Dec 2015 11:29:51 +0000 (19:29 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 19 Dec 2015 11:29:51 +0000 (19:29 +0800)
Fixes #7608

test/test_utils.py
youtube_dl/utils.py

index 86045e680409cf0b1ad764b88d44ca829b817803..e4e8d382518874378b003e2a73dd546ab32c4ab7 100644 (file)
@@ -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 = '''<?xml version="1.0" encoding="UTF-8"?>
index ee20c3d9b29b3066d69d47abbc03b3c5b1faa725..5b396ede8dd97aa441b134edf57146c4b0ab07a7 100644 (file)
@@ -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):