From 8a72d889b855faef3c48bde36efe84385b03c3f5 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 15 Sep 2013 00:28:23 +0200 Subject: [PATCH] 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. --- lib/svtplay_dl/utils/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/svtplay_dl/utils/__init__.py b/lib/svtplay_dl/utils/__init__.py index 89c61aa..04bc7ad 100644 --- a/lib/svtplay_dl/utils/__init__.py +++ b/lib/svtplay_dl/utils/__init__.py @@ -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