mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 01:17:15 +08:00
[nrk] Gracefully handle subtitle thousands with less than three digits
This commit is contained in:
parent
ce846a024d
commit
4c226a581f
@ -1154,6 +1154,8 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4')
|
||||
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)
|
||||
self.assertEqual(parse_dfxp_time_expr('00:00:01:10'), 1.01) # [nrk]
|
||||
self.assertEqual(parse_dfxp_time_expr('00:00:01:1'), 1.001) # [nrk]
|
||||
|
||||
def test_dfxp2srt(self):
|
||||
dfxp_data = '''<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
@ -2729,9 +2729,13 @@ 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)$', time_expr)
|
||||
if mobj:
|
||||
return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3).replace(':', '.'))
|
||||
return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3))
|
||||
|
||||
mobj = re.match(r'^(\d+):(\d\d):(\d\d)(?:\.|:)(\d{1,3})$', time_expr)
|
||||
if mobj:
|
||||
return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3)) + float("%03d" % int(mobj.group(4))) / 1000
|
||||
|
||||
|
||||
def srt_subtitles_timecode(seconds):
|
||||
|
Loading…
x
Reference in New Issue
Block a user