diff --git a/autosyl/assUtils.py b/autosyl/assUtils.py index 57dc0448c465f76ac10128d14d3dc3cdfa518088..5f5959a20b6a2fb1a7011a14f9fb5146fabf00ef 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: