$npx -y skills add jimliu/baoyu-skills --skill baoyu-youtube-transcriptDownloads YouTube video transcripts/subtitles and cover images by URL or video ID. Supports multiple languages, translation, chapters, and speaker identification. Caches raw data for fast re-formatting. Use when user asks to "get YouTube transcript", "download subtitles", "get ca
| 1 | # YouTube Transcript |
| 2 | |
| 3 | Downloads transcripts (subtitles/captions) from YouTube videos. Works with both manually created and auto-generated transcripts. No API key or browser required — uses YouTube's InnerTube API directly and automatically falls back to `yt-dlp` when YouTube blocks the direct API path. |
| 4 | |
| 5 | Fetches video metadata and cover image on first run, caches raw data for fast re-formatting. |
| 6 | |
| 7 | ## Script Directory |
| 8 | |
| 9 | Scripts in `scripts/` subdirectory. `{baseDir}` = this SKILL.md's directory path. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun. Replace `{baseDir}` and `${BUN_X}` with actual values. |
| 10 | |
| 11 | | Script | Purpose | |
| 12 | |--------|---------| |
| 13 | | `scripts/main.ts` | Transcript download CLI | |
| 14 | |
| 15 | ## Usage |
| 16 | |
| 17 | ```bash |
| 18 | # Default: markdown with timestamps (English) |
| 19 | ${BUN_X} {baseDir}/scripts/main.ts <youtube-url-or-id> |
| 20 | |
| 21 | # Specify languages (priority order) |
| 22 | ${BUN_X} {baseDir}/scripts/main.ts <url> --languages zh,en,ja |
| 23 | |
| 24 | # Without timestamps |
| 25 | ${BUN_X} {baseDir}/scripts/main.ts <url> --no-timestamps |
| 26 | |
| 27 | # With chapter segmentation |
| 28 | ${BUN_X} {baseDir}/scripts/main.ts <url> --chapters |
| 29 | |
| 30 | # With speaker identification (requires AI post-processing) |
| 31 | ${BUN_X} {baseDir}/scripts/main.ts <url> --speakers |
| 32 | |
| 33 | # SRT subtitle file |
| 34 | ${BUN_X} {baseDir}/scripts/main.ts <url> --format srt |
| 35 | |
| 36 | # Translate transcript |
| 37 | ${BUN_X} {baseDir}/scripts/main.ts <url> --translate zh-Hans |
| 38 | |
| 39 | # List available transcripts |
| 40 | ${BUN_X} {baseDir}/scripts/main.ts <url> --list |
| 41 | |
| 42 | # Force re-fetch (ignore cache) |
| 43 | ${BUN_X} {baseDir}/scripts/main.ts <url> --refresh |
| 44 | ``` |
| 45 | |
| 46 | ## Options |
| 47 | |
| 48 | | Option | Description | Default | |
| 49 | |--------|-------------|---------| |
| 50 | | `<url-or-id>` | YouTube URL or video ID (multiple allowed) | Required | |
| 51 | | `--languages <codes>` | Language codes, comma-separated, in priority order | `en` | |
| 52 | | `--format <fmt>` | Output format: `text`, `srt` | `text` | |
| 53 | | `--translate <code>` | Translate to specified language code | | |
| 54 | | `--list` | List available transcripts instead of fetching | | |
| 55 | | `--timestamps` | Include `[HH:MM:SS → HH:MM:SS]` timestamps per paragraph | on | |
| 56 | | `--no-timestamps` | Disable timestamps | | |
| 57 | | `--chapters` | Chapter segmentation from video description | | |
| 58 | | `--speakers` | Raw transcript with metadata for speaker identification | | |
| 59 | | `--exclude-generated` | Skip auto-generated transcripts | | |
| 60 | | `--exclude-manually-created` | Skip manually created transcripts | | |
| 61 | | `--refresh` | Force re-fetch, ignore cached data | | |
| 62 | | `-o, --output <path>` | Save to specific file path | auto-generated | |
| 63 | | `--output-dir <dir>` | Base output directory | `youtube-transcript` | |
| 64 | |
| 65 | ## Optional Environment Variables |
| 66 | |
| 67 | | Variable | Description | |
| 68 | |----------|-------------| |
| 69 | | `YOUTUBE_TRANSCRIPT_COOKIES_FROM_BROWSER` | Passed to `yt-dlp --cookies-from-browser` during fallback, e.g. `chrome`, `safari`, `firefox`, or `chrome:Profile 1` | |
| 70 | |
| 71 | ## Input Formats |
| 72 | |
| 73 | Accepts any of these as video input: |
| 74 | - Full URL: `https://www.youtube.com/watch?v=dQw4w9WgXcQ` |
| 75 | - Short URL: `https://youtu.be/dQw4w9WgXcQ` |
| 76 | - Embed URL: `https://www.youtube.com/embed/dQw4w9WgXcQ` |
| 77 | - Shorts URL: `https://www.youtube.com/shorts/dQw4w9WgXcQ` |
| 78 | - Video ID: `dQw4w9WgXcQ` |
| 79 | |
| 80 | ## Output Formats |
| 81 | |
| 82 | | Format | Extension | Description | |
| 83 | |--------|-----------|-------------| |
| 84 | | `text` | `.md` | Markdown with frontmatter (incl. `description`), title heading, summary, optional TOC/cover/timestamps/chapters/speakers | |
| 85 | | `srt` | `.srt` | SubRip subtitle format for video players | |
| 86 | |
| 87 | ## Output Directory |
| 88 | |
| 89 | ``` |
| 90 | youtube-transcript/ |
| 91 | ├── .index.json # Video ID → directory path mapping (for cache lookup) |
| 92 | └── {channel-slug}/{title-full-slug}/ |
| 93 | ├── meta.json # Video metadata (title, channel, description, duration, chapters, etc.) |
| 94 | ├── transcript-raw.json # Raw transcript snippets from YouTube API (cached) |
| 95 | ├── transcript-sentences.json # Sentence-segmented transcript (split by punctuation, merged across snippets) |
| 96 | ├── imgs/ |
| 97 | │ └── cover.jpg # Video thumbnail |
| 98 | ├── transcript.md # Markdown transcript (generated from sentences) |
| 99 | └── transcript.srt # SRT subtitle (generated from raw snippets, if --format srt) |
| 100 | ``` |
| 101 | |
| 102 | - `{channel-slug}`: Channel name in kebab-case |
| 103 | - `{title-full-slug} |