Skip to content

Commit a65aba0

Browse files
committed
Convert VTT to SRT
1 parent d54cc8f commit a65aba0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

post_vtt_converter.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{ source, target, metadata ->
2+
// Only process video files
3+
if (!f.video) {
4+
return
5+
}
6+
7+
// Detect Windows platform
8+
def is_windows = System.getProperty("os.name").toLowerCase().contains("windows")
9+
10+
// Path to convert_vtt_to_ass.py script
11+
def convert_script = is_windows ? "C:\\Users\\nattadasu\\Scripts\\convert_vtt_to_ass.py" : "/home/nattadasu/Scripts/convert_vtt_to_ass.py"
12+
def convert_py_file = new File(convert_script)
13+
if (!convert_py_file.exists()) {
14+
println("[VTT Converter] Error: convert_vtt_to_ass.py not found at ${convert_script}")
15+
return
16+
}
17+
18+
// Find VTT subtitle files derived from this video file
19+
target.dir.listFiles().findAll{ it.subtitle && it.ext == 'vtt' && it.isDerived(target) }.each { vtt_file ->
20+
try {
21+
println("[VTT Converter] Converting: ${vtt_file.name}")
22+
23+
// Call convert_vtt_to_ass.py using the venv python binary
24+
def python_bin = is_windows ? "C:\\Users\\nattadasu\\Scripts\\.venv\\Scripts\\python.exe" : "/home/nattadasu/Scripts/.venv/bin/python3"
25+
system python_bin, convert_script, vtt_file.toString()
26+
27+
// Delete original VTT file
28+
vtt_file.delete()
29+
30+
println("[VTT Converter] ✓ Converted ${vtt_file.name} to ASS")
31+
32+
} catch (Exception e) {
33+
println("[VTT Converter] Error processing ${vtt_file.name}: ${e.message}")
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)