From bbc8568fda32b263c53ef32f34955b41cfd9cd81 Mon Sep 17 00:00:00 2001 From: Sting <loic.allegre@ensiie.fr> Date: Tue, 25 Jul 2023 23:06:13 +0200 Subject: [PATCH] Fix several bugs on ASS file read/write --- autokara/autosyl/assUtils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autokara/autosyl/assUtils.py b/autokara/autosyl/assUtils.py index 5f5959a..4b819a1 100644 --- a/autokara/autosyl/assUtils.py +++ b/autokara/autosyl/assUtils.py @@ -9,7 +9,7 @@ def timeToDate(time): remainder_sec = (seconds % 60) + centiseconds hours = int(mins // 60) remainder_mins = int(mins % 60) - return f'{hours:02d}:{remainder_mins:02d}:{remainder_sec:.2f}' + return f'{hours:02d}:{remainder_mins:02d}:{remainder_sec:05.2f}' def dateToTime(date): @@ -29,7 +29,7 @@ def getSyls(ass_file): 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"); + LINES_KARA = re.compile(r"(?:Comment|Dialogue):.*(\d+:\d{2}:\d{2}.\d{2}),(\d+:\d{2}:\d{2}.\d{2}),([^,]*),([^,]*),(\d+),(\d+),(\d+),(?:(?!fx|template|code)\w)*,(.*)\n") RGX_TAGS = re.compile(r"\{\\k(\d+)\}([^\{\n\r]*)") for line in LINES_KARA.findall(CONTENT): syl_line = [] -- GitLab