home / skills / openclaw / skills / extract-youtube-transcript
This skill extracts plain-text YouTube transcripts using a local Python script, enabling easy retrieval, saving, and language-specific transcription for videos.
npx playbooks add skill openclaw/skills --skill extract-youtube-transcriptReview the files below or copy the command above to add this skill to your agents.
---
name: extract-youtube-transcript
version: 2.1.0
description: Extract plain-text transcripts from YouTube videos using a local Python script. Use when the user wants to fetch, extract, or get a transcript from a YouTube video URL, analyze YouTube video content as text, or needs subtitles/captions from a video.
---
# Extract YouTube Transcript
Fetches plain-text transcripts from YouTube videos using `extract_youtube_transcript.py` in this skill folder.
## Dependency
```bash
pip show youtube-transcript-api &>/dev/null || pip install youtube-transcript-api
```
## Quick Start
```bash
python extract_youtube_transcript.py "https://www.youtube.com/watch?v=VIDEO_ID"
```
Supported URL formats: `youtube.com/watch?v=`, `youtu.be/`, `/embed/`, `/live/`, `/shorts/`, or a raw 11-char video ID.
## Common Patterns
### Fetch with preferred language(s)
```bash
python extract_youtube_transcript.py "URL" --lang zh-Hant en
```
Pass languages in priority order. Falls back to any available transcript if none match.
### Save transcript to file
```bash
python extract_youtube_transcript.py "URL" --output transcript.txt
```
Text is printed to stdout and also written to the file.
### List available languages first
```bash
python extract_youtube_transcript.py "URL" --list-langs
```
Use this to discover what language codes are available before fetching.
## Language Codes
| Code | Language |
|------|----------|
| `en` | English |
| `zh-Hant` | Traditional Chinese |
| `zh-Hans` | Simplified Chinese |
| `ja` | Japanese |
| `ko` | Korean |
| `es` | Spanish |
## Error Handling
| Error | Cause | Recovery |
|-------|-------|----------|
| `TranscriptsDisabled` | Owner disabled captions | No transcript available |
| `NoTranscriptFound` | Requested lang not found | Run `--list-langs`, pick an available code |
| `VideoUnavailable` | Video is private/deleted | Verify the URL |
| `AgeRestricted` | Age-gated video | Auth not supported; no workaround |
| `InvalidVideoId` | Malformed URL or ID | Check the URL format |
## Workflow
1. Try a direct fetch first
2. If `NoTranscriptFound`, run `--list-langs` to see available codes, then re-fetch with `--lang <code>`
3. Save long transcripts to a file with `--output` for easier downstream processing
This skill extracts plain-text transcripts from YouTube videos using a local Python script. It accepts full YouTube URLs or raw 11-character IDs and prints the transcript to stdout or writes it to a file. Use language preferences or list available caption languages before fetching. It is a simple, offline wrapper around the youtube-transcript-api for fast transcript retrieval.
The script parses the provided YouTube URL or ID, queries the YouTube transcript service via the youtube-transcript-api Python package, and returns the caption text in plain form. You can pass one or more preferred language codes; the script will try them in order and fall back to any available transcript if none match. It supports listing available languages, saving output to a file, and common URL variants like youtu.be, embed, live, and shorts.
What URL formats are supported?
Full watch URLs, youtu.be short links, /embed/, /live/, /shorts/, or the raw 11-character video ID are all supported.
What if the requested language is not available?
Run the script with --list-langs to see available codes, then re-run with --lang using an available code. The script also falls back to any available transcript if no preferred languages match.
Which errors should I expect and how to recover?
Common errors include TranscriptsDisabled (captions turned off), NoTranscriptFound (requested lang missing), VideoUnavailable (private/deleted), AgeRestricted (no auth workaround), and InvalidVideoId (bad URL). Use --list-langs and verify the URL or video status to recover.