cd /news/ai-tools/why-fetching-youtube-transcripts-fai… · home › topics › ai-tools › article
[ARTICLE · art-178817] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

Why Fetching YouTube Transcripts Fails: What 6 Real Failures Taught Me

A developer building VidScope, a tool that analyzes YouTube videos from their transcripts, audited failed analyses and found 6 of 24 attempts (about 25%) failed, with four of the six caused not by IP bans but by code that only requested French and English captions. The fix lists all available transcripts, prefers manual over auto-generated captions, and falls back to any language, while a separate issue involves YouTube auto-dubbed audio tracks whose generated subtitles can be translations of a dub rather than the speaker's original words. The developer detects the original track by reading audio track IDs from the player response via a requests hook, noting the .4 suffix pattern is observed rather than documented.

recommendation

List all available transcripts and fall back to any language instead of hardcoding fr/en, and prefer manual captions over auto-generated ones to avoid dub-translated text.

more in playbook: Retrieval and RAG
by read4 min views5 publishedNov 30, 2026

I build VidScope, a tool that analyzes a YouTube video from its transcript. The first thing that goes wrong in a tool like this is not the AI. It is getting the transcript.

I went through every failed analysis in my logs. Over the period I looked at, 6 of 24 attempts failed (about 25%). I expected IP bans. Here is what the six really were:

IpBlocked, even through a residential proxy. Four failures out of six had nothing to do with rate limiting. My code only looked for French and English.

This is a small sample from one product, so treat the numbers as an illustration, not a benchmark.

I use youtube-transcript-api (version 1.2.4 when I wrote this). It is an unofficial library: it reads the same data the YouTube player reads. It can break whenever YouTube changes something, and automated access may go against YouTube's terms of service. Read them before building a product on it.

Also, if you copy older tutorials, note that the old YouTubeTranscriptApi.list_transcripts(video_id) static call no longer exists in 1.x. You instantiate the class and call api.list(video_id).

My first version asked for fr or en and gave up otherwise. The fix is to list what exists and decide afterwards:

from youtube_transcript_api import YouTubeTranscriptApi, NoTranscriptFound

api = YouTubeTranscriptApi()
transcript_list = api.list(video_id)

available = sorted(transcript_list, key=lambda t: t.is_generated)

try:
    transcript = transcript_list.find_transcript(["fr", "en"])
except NoTranscriptFound:
    if not available:
        raise
    transcript = available[0]          # any language beats no transcript

snippets = transcript.fetch()

Then tell the downstream model which language it is reading. A modern LLM reads Turkish or Hindi fine, as long as you do not pretend it is English.

This one surprised me. YouTube can offer auto-dubbed audio tracks, and each dubbed track comes with its own auto-generated subtitles. If you pick the first generated transcript, you may get a translation of a dub, which means quotes the speaker never said.

The player response lists the audio tracks. In what I observed, the IDs look like fr-FR.10 or en-US.4, and the original track is the one ending in .4. This is something I observed on real videos, not documented behavior, so I keep a fallback if the pattern is missing.

The library does not expose the audio tracks, so I read them from the response as it passes through, with a requests hook, without any extra request:

import requests

def watch_audio_tracks(session: requests.Session) -> list[str]:
    audio_ids: list[str] = []

    def read(resp, *_args, **_kwargs):
        if "/youtubei/" not in resp.url:
            return
        try:
            tracks = resp.json()["captions"]["playerCaptionsTracklistRenderer"]["audioTracks"]
            audio_ids[:] = [t.get("audioTrackId") or "" for t in tracks]
        except (ValueError, LookupError, TypeError, AttributeError):
            pass  # no captions, or the format changed: let the library deal with it

    session.hooks["response"].append(read)
    return audio_ids

Then the original language is the track ending in .4. With no dubbing, there is a single auto-generated language and that is the spoken one:

def lang(code: str) -> str:
    return code.split("-")[0].lower()          # "en-US" -> "en"

def original_language(transcripts, audio_ids):
    for audio_id in audio_ids:
        code, _, kind = audio_id.rpartition(".")
        if code and kind == "4":
            return lang(code)
    spoken = {lang(t.language_code) for t in transcripts if t.is_generated}
    return spoken.pop() if len(spoken) == 1 else None

I wrote unit tests for the cases where the answer is ambiguous (no audio info, several generated languages, a response with an unexpected shape). That code is the most fragile part of the whole pipeline, and it is the part where a silent wrong answer is worst.

Disabled subtitles, a private video, an age restriction: retrying will never help, and the user should get a clear message. An IP block, on the other hand, often goes away on the next attempt from a different IP.

from youtube_transcript_api import (
    AgeRestricted, InvalidVideoId, IpBlocked, NoTranscriptFound,
    RequestBlocked, TranscriptsDisabled, VideoUnavailable,
    VideoUnplayable, YouTubeRequestFailed,
)

def is_transient(exc: Exception) -> bool:
    return isinstance(exc, (IpBlocked, RequestBlocked, YouTubeRequestFailed,
                            requests.exceptions.RequestException))

The loop is deliberately boring. Five attempts, a fresh session each time, and a rotating residential proxy that gives a new IP per attempt:

for attempt in range(5):
    session = requests.Session()
    if proxy_url:
        session.proxies = {"http": proxy_url, "https": proxy_url}
    api = YouTubeTranscriptApi(http_client=session)
    try:
        ...  # pick the transcript and fetch it
        return result
    except TranscriptsDisabled:
        raise RuntimeError("Subtitles are disabled by the author.")
    except (VideoUnavailable, VideoUnplayable, AgeRestricted, InvalidVideoId):
        raise RuntimeError("This video is private, removed, age-restricted or the link is invalid.")
    except Exception as e:
        if is_transient(e) and attempt < 4:
            continue            # new session, new IP
        break

There is no exponential backoff here, and that is on purpose: the proxy changes the IP on every attempt, so waiting buys nothing. If you scrape from a single IP, the answer is different, and backoff with jitter is the right tool. I did not need it, so I will not pretend I measured it.

Before this loop, a failure was a generic "no transcript available", whatever the cause. Now the user sees one of three messages: the author disabled subtitles, the video is not accessible, or YouTube is temporarily blocking requests, try again in a minute. Two visitors in my logs retried the same video twice and then left. A clear message would have helped them more than a retry button.

── more in #ai-tools 4 stories · sorted by recency
── more on @vidscope 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-fetching-youtube…] indexed:0 read:4min 2026-11-30 · —