Add subtitle UI badge and VTT positioning

Documents the disclaimer, shows subtitles in admin movie badges, and offsets VTT subtitles from the bottom.
This commit is contained in:
Mathieu Moran
2026-01-25 01:00:48 -05:00
parent a9592ece7a
commit 891eb67e2d
4 changed files with 16 additions and 1 deletions
+9 -1
View File
@@ -122,7 +122,15 @@ async function convertSrtToVtt(filePath) {
const content = await fs.promises.readFile(filePath, "utf8");
const normalized = content.replace(/\r\n/g, "\n");
const body = normalized.replace(/(\d{2}:\d{2}:\d{2}),(\d{3})/g, "$1.$2");
const vtt = `WEBVTT\n\n${body.trim()}\n`;
const positioned = body.replace(
/^(\d{2}:\d{2}:\d{2}\.\d{3}\s+-->\s+\d{2}:\d{2}:\d{2}\.\d{3})(.*)$/gm,
(_match, timing, settings) => {
const tail = String(settings || "");
if (/\bline:/i.test(tail)) return `${timing}${tail}`;
return `${timing}${tail} line:90%`;
},
);
const vtt = `WEBVTT\n\n${positioned.trim()}\n`;
const vttPath = filePath.replace(/\.srt$/i, ".vtt");
await fs.promises.writeFile(vttPath, vtt, "utf8");
try { await fs.promises.unlink(filePath); } catch (_) {}