1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

subtitle_tt: make up an end time when it does not exists.

In some streams end time does not exists.
so we make our own from beginning + duration.
This commit is contained in:
Johan Andersson 2013-09-15 00:28:23 +02:00
parent 4d4e785dd5
commit 8a72d889b8

View File

@ -125,7 +125,14 @@ def subtitle_tt(options, subtitle):
if tag == "p":
if skip:
data = data + "\n"
data += '%s\n%s,%s --> %s,%s\n' % (i, node.attrib["begin"][:8], node.attrib["begin"][9:], node.attrib["end"][:8], node.attrib["end"][9:])
begin = node.attrib["begin"]
duration = node.attrib["dur"]
if not ("end" in node.attrib):
begin2 = begin.split(":")
duration2 = duration.split(":")
sec = float(begin2[2]) + float(duration2[2])
end = "%02d:%02d:%06.3f" % (int(begin[0]), int(begin[1]), sec)
data += '%s\n%s --> %s\n' % (i, begin.replace(".",","), end.replace(".",","))
data += '%s\n' % node.text.strip(' \t\n\r')
skip = True
i += 1