diff --git a/karaUtils.py b/karaUtils.py index 36dbd9f4a69567f9c1bc45973e2766aca9f91a74..fae95cd981687c124deeb206c5d3133752372e6c 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])