From d9bf06f403fececa50c7897f4797673ba6a4e596 Mon Sep 17 00:00:00 2001 From: Sting <loic.allegre@ensiie.fr> Date: Tue, 25 Jul 2023 00:31:32 +0200 Subject: [PATCH] Fix bugs on syls with no alphabetic characters --- autosyl/assUtils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autosyl/assUtils.py b/autosyl/assUtils.py index 57dc044..5f5959a 100644 --- a/autosyl/assUtils.py +++ b/autosyl/assUtils.py @@ -28,6 +28,7 @@ def getSyls(ass_file): META = [] with open(ass_file, 'r') as f: CONTENT = f.read() + strip_regex = re.compile('[^a-zA-Z]') LINES_KARA = re.compile(r"Comment:.*(\d+:\d{2}:\d{2}.\d{2}),(\d+:\d{2}:\d{2}.\d{2}),([^,]*),([^,]*),(\d+),(\d+),(\d+),karaoke,(.*)\n"); RGX_TAGS = re.compile(r"\{\\k(\d+)\}([^\{\n\r]*)") for line in LINES_KARA.findall(CONTENT): @@ -35,7 +36,7 @@ def getSyls(ass_file): lastTime = dateToTime(line[0]) syl_line_index = 0 for couple in RGX_TAGS.findall(line[7]): - if couple[1] != '' and not couple[1].isspace(): + if couple[1] != '' and not strip_regex.sub('', couple[1]) == '': syl_line.append([lastTime, couple[1], int(couple[0])]) syl_line_index += 1 if couple[1].isspace() and len(couple[1]) > 0 and syl_line_index > 0: -- GitLab