summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <jonheier@start.no>2007-10-01 20:51:03 +0200
committerJon Bergli Heier <jonheier@start.no>2007-10-01 20:51:03 +0200
commitd037149e75ba88a5d11ac7b74a2a9baf0e376638 (patch)
treef52e62fb4f0365d990f7b5054bb59f5b2c2b7356
parenta395b89a9f4729b0ee707d32074f3f66bcf6972a (diff)
Added get_duration in Event.
Fixed typo in add_lead_out.
-rw-r--r--pykfx/__init__.py9
1 files changed, 8 insertions, 1 deletions
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