From d037149e75ba88a5d11ac7b74a2a9baf0e376638 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 1 Oct 2007 20:51:03 +0200 Subject: Added get_duration in Event. Fixed typo in add_lead_out. --- pykfx/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pykfx/__init__.py b/pykfx/__init__.py index cac268d..71167db 100644 --- a/pykfx/__init__.py +++ b/pykfx/__init__.py @@ -107,6 +107,13 @@ class Event: def get_stripped(self): return re.sub(r'\{[^}]*\}', '', self.text) + def get_duration(self): + t = self.start.split(':') + st = int((float(t[-1]) + 60 * int(t[-2]) + 3600 * int(t[-3])) * 1000) + t = self.end.split(':') + en = int((float(t[-1]) + 60 * int(t[-2]) + 3600 * int(t[-3])) * 1000) + return en - st + def parse(self, s): s = s.split(': ', 1) self.kind = s[0].lower() @@ -155,7 +162,7 @@ class Event: self.start = '%01d:%02d:%05.2f' % (th, tm, ts) def add_lead_out(self, s): - t = self.snd.split(':') + t = self.end.split(':') ts = float(t[-1]) + 60 * int(t[-2]) + 3600 * int(t[-3]) + s th, ts = int(ts / 3600), ts % 3600 tm, ts = int(ts / 60), ts % 60 -- cgit v1.2.3