summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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