Playlist → RAG corpus

Video knowledge bases fail because nobody rewatches videos. Transcripts with per-line timings make a corpus you can search, and every answer can link to the exact second it came from.

What you get

  • Chunks that respect caption boundaries instead of cutting sentences
  • Metadata per chunk: video id, title, channel, start second
  • Citations that open the video at the right moment (&t=123s)

With an AI assistant

Connect the MCP server to Claude, ChatGPT or Cursor, then paste:

This one is usually code, not a chat. The API loop below lists every video, fetches timed transcripts and writes chunks ready for your embedding model.

With the API

Set GYT_API_KEY to a key from the developers page. Each transcript or list page costs one credit; checking a channel's latest uploads is free.

  1. 1. List every video (follow continuation until it is null)

    curl -s -H "Authorization: Bearer $GYT_API_KEY" \
      "https://getyoutubetranscript.com/api/v1/playlist?list=PLAYLIST_ID"
  2. 2. Fetch timed segments for each video (they are in data.segments)

    curl -s -H "Authorization: Bearer $GYT_API_KEY" \
      "https://getyoutubetranscript.com/api/v1/transcript?v=VIDEO_ID&timestamps=true"
  3. 3. Chunk on segment boundaries (Python)

    def chunks(video, segments, max_chars=1200):
        buf, start = [], None
        for s in segments:
            start = s["start"] if start is None else start
            buf.append(s["text"])
            if sum(len(t) for t in buf) > max_chars:
                yield {"text": " ".join(buf), "video_id": video, "start": start,
                       "url": f"https://youtu.be/{video}?t={int(start)}"}
                buf, start = [], None
        if buf:
            yield {"text": " ".join(buf), "video_id": video, "start": start,
                   "url": f"https://youtu.be/{video}?t={int(start)}"}

Limits to know

  • Transcripts cached before segments were stored come back without timings; chunk those by characters.
  • Re-fetching a transcript costs a credit each time, so store what you ingest.

Tools for this workflow

Questions

Is there a LangChain or LlamaIndex loader?

Yes. langchain-getyoutubetranscript and llama-index-readers-getyoutubetranscript return Documents with the same metadata and optional segments.

Will YouTube block my server?

No. The API fetches captions on its own servers, so your ingestion job never calls YouTube directly.

More workflows