Skip to content
Extraits de code Groupes Projets
Valider d9bf06f4 rédigé par Sting's avatar Sting
Parcourir les fichiers

Fix bugs on syls with no alphabetic characters

parent 514284a2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -28,6 +28,7 @@ def getSyls(ass_file): ...@@ -28,6 +28,7 @@ def getSyls(ass_file):
META = [] META = []
with open(ass_file, 'r') as f: with open(ass_file, 'r') as f:
CONTENT = f.read() 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:.*(\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]*)") RGX_TAGS = re.compile(r"\{\\k(\d+)\}([^\{\n\r]*)")
for line in LINES_KARA.findall(CONTENT): for line in LINES_KARA.findall(CONTENT):
...@@ -35,7 +36,7 @@ def getSyls(ass_file): ...@@ -35,7 +36,7 @@ def getSyls(ass_file):
lastTime = dateToTime(line[0]) lastTime = dateToTime(line[0])
syl_line_index = 0 syl_line_index = 0
for couple in RGX_TAGS.findall(line[7]): 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.append([lastTime, couple[1], int(couple[0])])
syl_line_index += 1 syl_line_index += 1
if couple[1].isspace() and len(couple[1]) > 0 and syl_line_index > 0: if couple[1].isspace() and len(couple[1]) > 0 and syl_line_index > 0:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter