fix(transcript): tlang en dernier recours + garde anti-blob
CI / build-and-test (push) Successful in 14m5s

Le fallback &tlang= peut renvoyer la piste source en un seul bloc
de plusieurs Ko (throttle YouTube) : il passait devant les pistes
directes et son blob anglais etait mis en cache comme 'fr'.
tlang desormais etape 3 (apres directes signees), isBlobTranscript()
refuse les cues uniques > 2000 chars (fetch, yt-dlp et post-dedupe).
Tests 27/27.
This commit is contained in:
2026-09-27 20:56:08 -04:00
parent a79831f406
commit a57bc0f7ae
3 changed files with 67 additions and 18 deletions
+13
View File
@@ -352,6 +352,19 @@ export function isEmptyTimedTextBody(text) {
return s.trim().length < 32;
}
/**
* True when parsed lines look like a degraded server-side translation blob
* rather than real cues: a single giant cue (several KB) instead of
* timestamped lines. YouTube serves these under throttle on `&tlang=`
* requests (source-language text, untranslated, in ONE event). Caching or
* labeling them as the target language would poison the UI + cache.
* A legitimate single-cue transcript (very short video) is always tiny.
* Pure and testable offline.
*/
export function isBlobTranscript(lines) {
if (!Array.isArray(lines) || lines.length !== 1) return false;
return String(lines[0]?.text || '').length > 2000;
}
/**
* Merge fetch candidates, signed yt-dlp URLs first (they carry a fresh
* `signature`/`expire` and are the only ones plain fetch can still read),