import time
from telemeta.util.xmltodict2 import *
+def parse_timestamp(value):
+ """
+ Parse a timestamp, either new HH:MM:SS.mmm format or old seconds format
+ """
+ if ':' in value:
+ if '.' in value:
+ value = value.split('.')[0]
+ comps = value.split(':')
+ comps = [ int(c) for c in comps ]
+ res = 0
+ for comp in comps:
+ res = res * 60 + comp
+ else:
+ res = int(value)
+ return res
+
class KDEnLiveSession(object):
for entry in entries:
id = entry['producer'].split('_')[0]
- t_in = int(entry['in'])/fps
- t_out = int(entry['out'])/fps
+ t_in = parse_timestamp(entry['in'])/fps
+ t_out = parse_timestamp(entry['out'])/fps
t_len = t_out - t_in
end = start + t_len
res.append({ 'id': str(id), 't': start, 'in': t_in, 'out': t_out })
title = ''
for attr in self.session['children']:
- if 'playlist' in attr['name']:
+ if 'playlist' in attr['name'] and 'children' in attr:
for att in attr['children']:
marker = {}
if 'name' in att['attributes']: