feat: multi-language subtitle support (SRT/VTT)

This commit is contained in:
Nice Try
2026-06-26 20:12:48 +00:00
parent 33e5e61b11
commit 7d0f976da0
6 changed files with 98 additions and 6 deletions
+6 -1
View File
@@ -1,4 +1,4 @@
import { buildSubtitleTrackMap, languageCodeToLabel, normalizeSubtitleLang } from '@/lib/subtitles'
import { buildSubtitleTrackMap, convertSrtToVtt, languageCodeToLabel, normalizeSubtitleLang } from '@/lib/subtitles'
function assert(condition: unknown, message: string) {
if (!condition) {
@@ -34,4 +34,9 @@ assert(normalizeSubtitleLang('PT-br') === 'pt-BR', 'pt-BR normalization failed')
assert(languageCodeToLabel('fil') === 'Filipino', 'Filipino label failed')
assert(!tracks.has('unrelated'), 'unrelated subtitle should not create a track group')
const converted = convertSrtToVtt('1\n00:00:01,250 --> 00:00:04,500\nHello captions\n')
assert(converted.startsWith('WEBVTT'), 'SRT conversion should emit WEBVTT header')
assert(converted.includes('00:00:01.250 --> 00:00:04.500'), 'SRT conversion should rewrite comma timestamps')
assert(!converted.includes('00:00:01,250'), 'SRT conversion should not keep comma timestamps')
console.log('subtitle parser verification passed')