syncing scripts

This commit is contained in:
2026-01-11 15:10:56 -05:00
parent 362c06dab4
commit 203fc69393
24 changed files with 1982 additions and 172 deletions
@@ -0,0 +1,28 @@
import pysubs2
import os
def validate_and_repair_srt(srt_path):
"""
Validates an SRT file and attempts to repair it using pysubs2.
Args:
srt_path (str): Path to the SRT file.
Returns:
bool: True if valid/repaired, False if critical error.
"""
if not os.path.exists(srt_path):
return False
print(f"Validating SRT: {srt_path}...")
try:
# Load the subtitle file. pysubs2 parser is robust and handles many errors automatically.
subs = pysubs2.load(srt_path)
# Save it back ensures consistent formatting and fixes minor syntax issues
subs.save(srt_path)
print("SRT validation passed (file re-saved with correct formatting).")
return True
except Exception as e:
print(f"Warning: SRT validation failed: {e}")
return False