From: Gael Le Mignot Date: Thu, 21 Apr 2022 09:06:03 +0000 (+0200) Subject: Added support for more recent kdeenlive files X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6e59be5a5c2252d6d069b6714106230ccd907730;p=telemeta.git Added support for more recent kdeenlive files --- diff --git a/telemeta/util/kdenlive/session.py b/telemeta/util/kdenlive/session.py index 17525c61..d9ed7eb0 100644 --- a/telemeta/util/kdenlive/session.py +++ b/telemeta/util/kdenlive/session.py @@ -36,6 +36,22 @@ 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): @@ -74,8 +90,8 @@ 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 }) @@ -124,7 +140,7 @@ class KDEnLiveSession(object): 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']: