AgentSkillsCN

youtube

当用户询问“YouTube”“我的视频”“我的频道”“YouTube搜索”“视频评论”“播放列表”“列出视频”“频道统计”“视频详情”“下载视频”“获取字幕”“视频字幕”“总结频道”“频道最新视频”“视频时间戳”“链接至时间戳”,或提及YouTube相关操作时,应使用此技能。该技能提供YouTube Data API的集成功能,并借助yt-dlp从任意频道下载视频、字幕及元数据。同时,还内置了全面的频道视频摘要工作流。

SKILL.md
--- frontmatter
name: youtube
description: This skill should be used when the user asks about "youtube", "my videos", "my channel", "youtube search", "video comments", "playlists", "list videos", "channel stats", "video details", "download video", "get transcript", "video subtitles", "summarize channel", "latest videos from channel", "video timestamp", "link to timestamp", or mentions YouTube operations. Provides YouTube Data API integration and yt-dlp for downloading videos, transcripts, and metadata from any channel. Includes workflow for comprehensive channel video summaries.
version: 0.4.0

YouTube Skill

Search YouTube, list videos, channels, playlists, view comments, download videos, and extract transcripts.

First-Time Setup

For API commands (your channel data): Run npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/gmail.ts auth to authenticate with Google. Tokens are stored per-project in .claude/google-skill.local.json.

For yt-dlp commands (any public content): Install yt-dlp with brew install yt-dlp (no auth needed).

Using Your Own Credentials (Optional)

By default, this skill uses embedded OAuth credentials. To use your own Google Cloud project instead, save your credentials to ~/.config/google-skill/credentials.json.

API Commands (Requires OAuth)

bash
# List your YouTube channels
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts channels

# Get channel details
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts channel <channelId>

# List your videos
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts videos
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts videos --max=20
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts videos --channel=UC...

# Get video details
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts video <videoId>

# List your playlists
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts playlists

# Get playlist items
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts playlist <playlistId>

# Search YouTube
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts search --query="typescript tutorial"
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts search --query="coding" --type=video --max=5

# Get video comments
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts comments <videoId> --max=50

yt-dlp Commands (No Auth Required)

These commands use yt-dlp to access any public YouTube content without OAuth.

Get Video Metadata

bash
# Get detailed info about any video
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-info dQw4w9WgXcQ
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-info "https://youtube.com/watch?v=..."

List Channel Videos

bash
# List videos from any public channel (by @handle, channel ID, or URL)
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-channel @mkbhd
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-channel UCXuqSBlHAE6Xw-yeJA0Tunw --max=50
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-channel "https://youtube.com/@channelname"

Get Transcripts/Subtitles

bash
# Get video transcript (auto-generated or manual subtitles)
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts transcript dQw4w9WgXcQ
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts transcript dQw4w9WgXcQ --lang=es

Returns both the full text and timestamped segments for analysis.

Transcript Output Format:

json
{
  "success": true,
  "data": {
    "language": "en",
    "text": "Full transcript text joined together...",
    "segments": [
      { "start": 0.16, "text": "First segment text" },
      { "start": 4.55, "text": "Second segment text" },
      ...
    ],
    "segmentCount": 566
  }
}

Creating Timestamped Links

Use segment timestamps to create deep links to specific moments in videos:

URL Format: https://www.youtube.com/watch?v={videoId}&t={seconds}s

Examples:

  • Timestamp 120.5 seconds → https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=120s
  • Timestamp 3661.2 seconds (1:01:01) → https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=3661s

Converting segment.start to link:

code
segment.start = 289.12
videoId = "rHdMviAhDtE"
link = https://www.youtube.com/watch?v=rHdMviAhDtE&t=289s

Markdown format for summaries:

markdown
[4:49](https://www.youtube.com/watch?v=rHdMviAhDtE&t=289s) - Eddie Bauer review starts

Helper: Convert seconds to MM:SS or HH:MM:SS:

  • 289 seconds → 4:49 (Math.floor(289/60) + ":" + (289%60).toString().padStart(2,'0'))
  • 3661 seconds → 1:01:01

Download Videos

bash
# Download video (best quality)
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ

# Download to specific directory
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ --output=./videos

# Download specific quality
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ --format=720p
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ --format=mp4

# Extract audio only (MP3)
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ --audio-only

# Download with subtitles
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts download dQw4w9WgXcQ --subtitles --sub-lang=en

Download Playlists/Channels

bash
# Download entire playlist
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-playlist "https://youtube.com/playlist?list=PL..."

# Download first 5 videos
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-playlist "https://youtube.com/playlist?list=..." --max=5

# Download videos 10-20
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-playlist "https://youtube.com/playlist?list=..." --start=10 --end=20

# Download as audio
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts dl-playlist "https://youtube.com/playlist?list=..." --audio-only --output=./music

Download Options

OptionDescription
--output=DIROutput directory (default: current)
--format=FMTFormat: best, mp4, 720p, 480p, 360p
--audio-onlyExtract audio as MP3
--subtitlesDownload subtitles with video
--sub-lang=LANGSubtitle language code (default: en)
--max=NMax videos for playlist download
--start=NStart from video N in playlist
--end=NEnd at video N in playlist

Video IDs

Video IDs are the 11-character code in YouTube URLs:

  • https://www.youtube.com/watch?v=dQw4w9WgXcQ → ID is dQw4w9WgXcQ
  • https://youtu.be/dQw4w9WgXcQ → ID is dQw4w9WgXcQ

Channel References

Channels can be referenced by:

  • Handle: @mkbhd
  • Channel ID: UCXuqSBlHAE6Xw-yeJA0Tunw
  • Full URL: https://youtube.com/@mkbhd

Output

All commands return JSON with success and data fields.

Help

bash
npx tsx ${CLAUDE_PLUGIN_ROOT}/scripts/youtube.ts --help

Channel Summary Workflow

For comprehensive summaries of a channel's recent videos (with transcripts, key points, and external links), see CHANNEL-SUMMARY.md in this skill directory.

Quick workflow:

  1. List channel videos: pnpm run youtube dl-channel "@channelname" --max=10
  2. Get transcripts for each video (run in parallel)
  3. Create summaries with key points and insights
  4. Research and add external links for people, companies, books mentioned
  5. Export as markdown

This workflow is ideal for:

  • Creating research summaries from tech channels
  • Extracting insights from interview series
  • Documenting book/product recommendations from creators
  • Building knowledge bases from educational content