{"slug": "what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production", "title": "What breaks after RequestBlocked when you run YouTube transcripts in production", "summary": "A developer operating Subtext, a single-process FastAPI service that serves YouTube transcripts via web, REST API, and a remote MCP server, documented five production failure modes that appear after the initial cloud-IP RequestBlocked error. The writeup covers PO-token gates (PoTokenRequired, &exp=xpe/xpv) that proxies cannot clear, proxy authentication and sticky-session traps, bandwidth costs of scraping watch pages versus calling InnerTube's /youtubei/v1/player with a $fields projection, and thread-pool exhaustion from blocking calls in FastAPI's default endpoints. The fixes include detecting token markers on caption URLs, alternating ANDROID and IOS client contexts, and opening a fresh session per proxy retry.", "body_md": "If you search for `youtube-transcript-api RequestBlocked` right now, you will find dozens of posts that stop at the same three bullets: run it locally, buy a residential proxy, or pay a scraping actor.\n\nThat is enough to get a one-off script running on AWS, GCP, or Railway, but a real service hits harder problems in its first busy week.\n\nWhile building and operating [Subtext](https://youtubevideototranscript.com), a single-process FastAPI service that serves YouTube transcripts on the web, over a REST API, and through a remote MCP server, the initial cloud IP block turned out to be the easy part. Here are five failure modes we actually hit after getting past `RequestBlocked`, and what fixed them.\n\nA classic trap when deploying a transcript fetcher is testing it with one famous video ID (almost always `dQw4w9WgXcQ`) in a CI health check or right after a deploy.\n\nYouTube does not enforce anti-bot rules uniformly across every video ID and every CDN edge. Popular videos can return captions cleanly from a cloud IP that blocks 80% of normal long-tail uploads with `RequestBlocked` or a sign-in wall (`Sign in to confirm you're not a bot`, sent with a curly typographic apostrophe `’` in the playability reason string).\n\nTest new infrastructure against a small rotating set of ordinary, recently uploaded videos, and never treat a single green smoke check as proof that your server IP is clean.\n\n`PoTokenRequired` (`&exp=xpe`) does not care about your proxy\nOnce you move past basic datacenter IP bans, you run into a different failure class: YouTube injects `&exp=xpe` or `&exp=xpv` into the caption track `baseUrl`. In `youtube-transcript-api` v1.2+, this surfaces as `PoTokenRequired`.\n\nThrowing more rotating residential proxies or browser cookies at the exact same client request will not clear a PO-token gate. You have to detect the token marker explicitly on the caption track URL before you waste retries on it:\n\n``` python\nPO_TOKEN_MARKERS = (\"&exp=xpe\", \"&exp=xpv\")\n\ndef needs_po_token(caption_url: str) -> bool:\n    return any(marker in caption_url for marker in PO_TOKEN_MARKERS)\n```\n\nIn our primary fetcher, we skip the HTML watch page and call InnerTube (`POST https://www.youtube.com/youtubei/v1/player`) directly, alternating client contexts (` ANDROID` and `IOS`) when a track comes back PO-token-gated or blocked. If the primary source still cannot retrieve a clean track, we hand off to a bounded secondary fallback instead of burning ten retries on the same dead path.\n\nMost developers hit two proxy traps in their first week:\n\n`407 Proxy Authentication Required` when paired with `WebshareProxyConfig`.` requests.Session` against a sticky proxy gateway, you keep hitting YouTube from the exact same burned exit IP.\nThere is also a bandwidth cost most tutorials leave out. Residential proxies bill per gigabyte. Fetching a full YouTube watch page HTML document just to parse out `captionTracks` pulls hundreds of kilobytes per video. Calling `/youtubei/v1/player` with a `$fields` projection mask requests only the three slices you actually need:\n\n```\nFIELDS = (\n    \"playabilityStatus(status,reason,errorScreen),\"\n    \"captions.playerCaptionsTracklistRenderer\"\n    \"(captionTracks,translationLanguages,audioTracks,defaultAudioTrackIndex),\"\n    \"videoDetails(videoId,title,author,channelId,lengthSeconds)\"\n)\n```\n\nOne projected player response plus one caption XML download uses a fraction of the bandwidth of scraping the watch page, and opening a fresh session per proxy retry ensures each attempt exits through a new residential IP.\n\nIf 25 users or AI agents request the same newly published podcast at the same time on a cold cache, naive code launches 25 identical upstream fetches in parallel. Even worse, in FastAPI, running blocking `requests` or `youtube-transcript-api` calls inside default `def` endpoints dumps them onto AnyIO's shared 40-thread worker pool. When YouTube stalls or throttles, all 40 threads sit waiting on sockets and your entire app stops answering even cached requests and health checks.\n\nFour small pieces keep one busy link from taking down the server:\n\n`(video_id, lang.lower(), translate.lower())`. Only one upstream fetch runs at a time; later callers wait on that lock and read the cached row from SQLite.`no_captions`, `age_restricted`, and `video_unavailable` as negative results so nobody repeatedly hits YouTube for a captionless video. Put temporary failures (`429`, timeouts, proxy refusals) on a short 60-second cooldown instead of locking out a working video for hours.`ThreadPoolExecutor` with a queue cap and per-request deadline, leaving AnyIO's shared pool for fast local SQLite reads, rendering, and compression.\nHere is the minimal single-flight lock we use in Python (`_Flights` in our transcript service):\n\n``` python\nimport threading\nfrom contextlib import contextmanager\n\nclass Flights:\n    def __init__(self) -> None:\n        self._guard = threading.Lock()\n        self._locks: dict[tuple[str, str, str], list] = {}\n\n    @contextmanager\n    def __call__(self, key: tuple[str, str, str]):\n        with self._guard:\n            entry = self._locks.setdefault(key, [threading.Lock(), 0])\n            entry[1] += 1\n        entry[0].acquire()\n        try:\n            yield\n        finally:\n            entry[0].release()\n            with self._guard:\n                entry[1] -= 1\n                if entry[1] == 0:\n                    self._locks.pop(key, None)\n```\n\nAlso watch out for `NoTranscriptFound` vs `TranscriptsDisabled` when selecting languages. A video often has `en-US` or `en-GB` instead of bare `en`, or only an auto-generated track. Match language prefixes before giving up, and be careful with YouTube's `.translate()` endpoint, which hits `429` much faster than regular caption fetches.\n\nOnce you have a cached, bounded transcript backend running cleanly, the next bottleneck shows up on the client side: people building workflows in Claude Code, Cursor, or custom agents do not want to install `yt-dlp`, debug residential proxies, or maintain a local Python environment just to read a lecture or conference talk.\n\nWe exposed the same backend over two thin surfaces:\n\n`GET /api/v1/transcript`) returning JSON, plain text, Markdown, SRT, or WebVTT, plus a free `GET /api/v1/languages` lookup. Details and OpenAPI 3.1 schema live on the `https://youtubevideototranscript.com/mcp` supporting both OAuth 2.1 with PKCE and Bearer API keys, exposing `get_transcript` and `list_languages`.\nIn Claude Code, connecting it is one command:\n\n```\nclaude mcp add --transport http subtext https://youtubevideototranscript.com/mcp \\\n  --header \"Authorization: Bearer $SUBTEXT_API_KEY\"\n```\n\nBecause both surfaces share the exact same SQLite cache, single-flight coordinator, and credit accounting (failed fetches never charge a credit), agents never inherit local IP-block headaches or duplicate work.\n\nIf you only run occasional scripts from a laptop, plain `youtube-transcript-api` is still hard to beat. Once you deploy it behind a server or an AI agent pipeline, plan for the layers after `RequestBlocked`:\n\n`&exp=xpv` PO-token tracks early so you do not burn proxy credits retrying them.\nIf you want the full checklist of Python `RequestBlocked` fixes or would rather not maintain proxy infrastructure yourself, we keep both a [Python cloud IP-block troubleshooting guide](https://youtubevideototranscript.com/youtube-transcript-api-python-blocked) and a [YouTube MCP server setup guide](https://youtubevideototranscript.com/youtube-mcp-server) up to date on [Subtext](https://youtubevideototranscript.com).", "url": "https://wpnews.pro/news/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production", "canonical_source": "https://dev.to/subtext/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production-aa4", "published_at": "2026-12-01 20:06:23+00:00", "updated_at": "2026-12-01 20:14:08.126556+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Subtext", "YouTube", "FastAPI", "youtube-transcript-api", "InnerTube", "AnyIO", "WebshareProxyConfig"], "also_reported_by": [], "takeaway": "Detect PO-token markers (&exp=xpe, &exp=xpv) on caption track URLs before retrying, and call InnerTube's /youtubei/v1/player with a $fields projection instead of scraping the watch page to cut residential-proxy bandwidth per video.", "recommendation": {"advice": "Test transcript fetchers against a rotating set of ordinary recent videos, not one famous ID, and open a fresh session per proxy retry so each attempt exits a new IP.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production", "markdown": "https://wpnews.pro/news/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production.md", "text": "https://wpnews.pro/news/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production.txt", "jsonld": "https://wpnews.pro/news/what-breaks-after-requestblocked-when-you-run-youtube-transcripts-in-production.jsonld"}}