Update utils/helpers.py
Browse files- utils/helpers.py +4 -1
utils/helpers.py
CHANGED
|
@@ -40,7 +40,10 @@ def clean_and_validate_srt(srt_content):
|
|
| 40 |
match = first_block_pattern.search(srt_content)
|
| 41 |
if match: srt_content = srt_content[match.start():]
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
matches = pattern.findall(srt_content)
|
| 45 |
|
| 46 |
def corrigir_timestamp(timestamp):
|
|
|
|
| 40 |
match = first_block_pattern.search(srt_content)
|
| 41 |
if match: srt_content = srt_content[match.start():]
|
| 42 |
|
| 43 |
+
# Same `(?:\n|$)` fix as parse_srt in srt_utils.py — a last block with
|
| 44 |
+
# empty text has no trailing newline for a mandatory `\n` to match,
|
| 45 |
+
# which silently dropped it (and its block number) from `matches`.
|
| 46 |
+
pattern = re.compile(r"(\d+)\s*\n([^-\n]+?) --> ([^-\n]+?)\s*(?:\n|$)((?:(?!^\d+\s*\n).+\n?)*)", re.MULTILINE)
|
| 47 |
matches = pattern.findall(srt_content)
|
| 48 |
|
| 49 |
def corrigir_timestamp(timestamp):
|