YouTube
YouTube captions: how en.* broke our transcript API
Published
Measured against https://www.youtube.com/watch?v=dQw4w9WgXcQ (subtitle tracks) and https://www.youtube.com/watch?v=jNQXAC9IVRw (transcript endpoint) on 2026-12-03.
This is a post-mortem of a bug we caused ourselves, written while the reproduction still works. The transcript endpoint stopped answering with a 429 for some links and not others, the cause was a wildcard we had copied from a tutorial, and the fix is one option on a command line. What makes it worth publishing is the shape of the mistake. Nothing was broken in the code; a language pattern that looks like "give me English" meant "give me every track whose name begins with en", and on a popular video that is not one request. It is seven.
What a caption request actually is
A YouTube video can carry two independent kinds of caption track. A manual track is text a human uploaded, timed to the video. An automatic track is what YouTube's own speech recognition produced, and it exists in two flavours: the recognition for the spoken language, and machine translations of that recognition into other languages, generated on demand. Our transcript endpoint resolves a link, asks for the track in the language requested, parses the WebVTT it receives, strips the markup, and merges the rolling cues that auto captions repeat. The response says which kind of track was used, which is the one field a caller should look at before trusting the text:
{
"ok": true,
"platform": "youtube",
"title": "Me at the zoo",
"durationSec": 19,
"language": "en",
"source": "manual",
"segmentCount": 6,
"charCount": 217,
"segments": [
{ "start": 1.2, "end": 3.36, "text": "All right, so here we are, in front of the elephants" },
{ "start": 5.32, "end": 7.97, "text": "the cool thing about these guys is that they have really..." }
]
}source: manual, six segments, 217 characters for a 19-second video. Those numbers are the whole payload of the feature: no audio is transcribed on our side, the text is the platform's, and the endpoint's job is limited to fetching and cleaning it. If the video has no track at all, there is nothing to fetch, and the endpoint says so rather than guessing.
The bug, reproduced
The pattern we used was en.* — the wildcard form that appears in a lot of examples. yt-dlp treats each entry in --sub-langs as a regular expression, so this one means "every track whose identifier starts with en". Asking the video used for this test what it has shows why that is not a synonym for "English":
en English
en-en English from English
en-orig English (Original)
en-de-DE English from German (Germany)
en-ja English from Japanese
en-pt-BR English from Portuguese (Brazil)
en-es-419 English from Spanish (Latin America)
(945 automatic caption rows in total on this video; the manual
subtitle section begins after them.)Seven matches, one of them the track we wanted. Four of the other six are machine translations of other languages' recognition into English — tracks that exist because someone else's auto captions were translated, and which contain nothing about the original audio. The naming convention explains the confusion. A translated track is named target-source: en-de-DE is English generated from German, not German generated from English. A wildcard on the source language therefore cannot be written as a prefix, because the source language sits at the end of the identifier. That one sentence is the entire bug. So the request went out with seven tracks selected, which means seven timedtext fetches in quick succession. Here is what happened:
[info] dQw4w9WgXcQ: Downloading subtitles: en, en-en, en-orig, en-de-DE, en-ja, en-pt-BR, en-es-419
[info] Writing video subtitles to: ...[dQw4w9WgXcQ].en.vtt
[info] Writing video subtitles to: ...[dQw4w9WgXcQ].en-en.vtt
[info] Writing video subtitles to: ...[dQw4w9WgXcQ].en-orig.vtt
ERROR: Unable to download video subtitles for 'en-de-DE': HTTP Error 429: Too Many RequestsThree tracks written, and the fourth — the first translated one in the queue — was refused with HTTP 429. In the endpoint this surfaced as a throttling error on a video that has captions in the requested language, which is the worst kind of bug: the feature worked, and the destination refused to talk to us because we had arrived four times in quick succession, three of them already served. What the 429 refused was the first translated track in the queue, as the fifth subtitle request in a row — we can say that much from the output and no more, since the rate limiter's own reasoning is not visible to us. What is visible is the arithmetic: a wildcard turned one request into seven, and the endpoint gave up partway through. Every one of those seven was a translated track except the one we wanted, which is the part that makes the wildcard indefensible even when it happens to succeed.
The fix
Two changes, both of which are configuration rather than code. The first is to stop using a pattern where an exact language code will do. The endpoint takes a language tag and passes it through as a literal, so a request for en asks for en — not for everything beginning with en. The second is to tell the extractor that translated tracks are out of scope entirely, so that even a caller who passes a wildcard cannot fan a single request out into a dozen:
yt-dlp --write-auto-subs --sub-langs "en" \
--extractor-args "youtube:skip=translated_subs" \
--sub-format vtt <url>
[info] dQw4w9WgXcQ: Downloading subtitles: en
[info] Writing video subtitles to: ...[dQw4w9WgXcQ].en.vtt
(one track queued, one file written, no 429)One subtitle download instead of seven, one request instead of four attempted, and the text is the track the caller asked for instead of whichever translated track happened to be written first. The same output also removes a subtle correctness bug that would have outlived the 429: with seven tracks racing, the parser could have picked up a translation of a different language's recognition and returned it as "English", which is a wrong answer dressed as a right one.
Why we do not run speech recognition
The obvious next idea is to ignore the platform's tracks and transcribe the audio ourselves. We do not, for four reasons that are worth being explicit about. Transcripts here are the platform's own text. The endpoint reports source: manual or source: auto, and a reader can tell which of the two they are holding. Running recognition on the audio would produce a third category with no such label — text that looks identical to a manual track, was produced by a different system, and carries that system's errors silently. The cost is the second reason. Recognition needs a model, a GPU or a long CPU pass, and minutes per video, against a service that answers in seconds and holds two jobs at a time across the whole box. A single transcript request would occupy the slot for a download and a half. Third, the accuracy is not ours to guarantee. Automatic captions from the platform are imperfect and everyone knows that; a transcript we generated ourselves would be judged as ours, and a proper noun mangled by our recogniser is a support ticket, while the same error in the platform's track is expected. Fourth, there are platforms where the answer is structurally no captions: TikTok, Instagram, X, Facebook, SoundCloud, Dailymotion and Streamable essentially never publish a caption track. The endpoint answers those with a specific "no captions" response rather than a server error, because there is nothing to extract and no amount of retrying changes it. Speech recognition would turn that honest empty answer into an expensive guess. So the transcript feature stays what it is: fetch the track the platform published, in the exact language asked for, clean it, and say where it came from.