AgentSkillsCN

youtube-transcript

获取 YouTube 视频的字幕与元数据。适用于用户分享 YouTube 链接、希望了解所观视频的背景信息,或需要对视频进行转录时使用。

SKILL.md
--- frontmatter
name: youtube-transcript
description: Fetch YouTube video transcripts and metadata. Use when the user shares a YouTube link, wants context on a video they watched, or needs a video transcribed.
argument-hint: <youtube-url> [language]

Fetch a YouTube video's transcript and metadata so you have full context on what the user watched.

Usage

Run the fetch script with the provided URL:

bash
python3 .github/skills/youtube-transcript/scripts/fetch-transcript.py "$ARGUMENTS"

Uses only Python stdlib — no pip install or dependencies needed.

Arguments

ArgumentRequiredDescription
URL or video IDYesYouTube URL (youtube.com/watch?v=..., youtu.be/...) or bare video ID
--lang CODENoLanguage code (default: en). Example: --lang es
--timedNoInclude timestamps in output

Examples

bash
# Basic transcript
python3 .github/skills/youtube-transcript/scripts/fetch-transcript.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# Spanish transcript
python3 .github/skills/youtube-transcript/scripts/fetch-transcript.py "https://youtu.be/dQw4w9WgXcQ" --lang es

# With timestamps
python3 .github/skills/youtube-transcript/scripts/fetch-transcript.py "dQw4w9WgXcQ" --timed

Output

The script prints video metadata followed by the full transcript:

code
# Video: <title>
Channel: <channel>
Duration: <duration>
Language: <lang>
URL: <url>
Available languages: <list>

## Transcript
<full transcript text>

How It Works

Uses YouTube's innertube API (same as the Android app) to fetch caption data directly. No API key, no pip packages, no authentication needed.

Notes

  • Default language is English; specify --lang for other languages
  • Falls back to English, then first available language if requested language not found
  • If no transcript is available, the script reports an error