From 0f7775b2231b6a9d7c887bb5d7838ba7d2590e71 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 14 Aug 2019 11:25:08 +0200 Subject: [PATCH] Now retrieve all the syllabs and their duration from the ass file --- karaUtils.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/karaUtils.py b/karaUtils.py index 36dbd9f..fae95cd 100755 --- a/karaUtils.py +++ b/karaUtils.py @@ -11,18 +11,22 @@ with open(FILE, 'r') as f: CONTENT = f.read() LINES_KARA = re.compile(r"Comment:.*(\d+:\d{2}:\d{2}.\d{2}),(\d+:\d{2}:\d{2}.\d{2}),.*,karaoke,(.*)\n"); -print(LINES_KARA) + +RGX_TAGS = re.compile(r"\{\\k(\d+)\}([^\{\n\r]*)") LINES = { - 'start': set(), - 'end': set(), - 'text': set() + 'start': [], + 'end': [], + 'text': [] } for line in LINES_KARA.findall(CONTENT): - print(line) - LINES['start'] = line[0] - LINES['end'] = line[1] - LINES['text'] = line[2] + LINES['start'].append(line[0]) + LINES['end'].append(line[1]) + text = [] + for couple in RGX_TAGS.findall(line[2]): + text.append((couple[0], couple[1])) + LINES['text'].append(text) -print(LINES) +for i in range (0, len(LINES['start'])): + print(LINES['start'][i], LINES['end'][i], LINES['text'][i]) -- GitLab