youtube-content

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

YouTube Content

YouTube 内容处理

Extract transcripts and metadata from YouTube videos for analysis.
提取YouTube视频的字幕文稿和元数据以进行分析。

Workflow

工作流程

  1. Extract video ID from URL
  2. Run fetch script from skill directory
  3. Present metadata summary to user
  4. Apply requested analysis mode to transcript
  5. Save analysis and raw transcript to knowledge base (auto, use
    --no-save
    to skip)
  1. 从URL中提取视频ID
  2. 运行技能目录中的获取脚本
  3. 向用户展示元数据摘要
  4. 对字幕文稿应用请求的分析模式
  5. 将分析结果和原始字幕文稿保存到知识库(自动执行,使用
    --no-save
    参数可跳过)

Fetch Script

获取脚本

Run from the skill directory (
~/.claude/skills/youtube-content/
):
bash
uv run ~/.claude/skills/youtube-content/scripts/fetch_youtube.py "https://youtube.com/watch?v=VIDEO_ID"
Options:
  • --metadata-only
    - Skip transcript extraction
  • --transcript-only
    - Skip metadata extraction
  • --with-segments
    - Include timestamped segments (for quote extraction)
Output: JSON with
{video_id, metadata, transcript, errors}
By default, transcript contains only
text
and
language
. Use
--with-segments
when timestamps are needed (e.g., Quotes mode).
从技能目录(
~/.claude/skills/youtube-content/
)中运行:
bash
uv run ~/.claude/skills/youtube-content/scripts/fetch_youtube.py "https://youtube.com/watch?v=VIDEO_ID"
可选参数:
  • --metadata-only
    - 跳过字幕文稿提取
  • --transcript-only
    - 跳上元数据提取
  • --with-segments
    - 包含带时间戳的片段(用于语录提取)
输出格式:JSON,包含
{video_id, metadata, transcript, errors}
默认情况下,字幕文稿仅包含
text
language
字段。当需要时间戳时(例如语录模式),请使用
--with-segments
参数。

Supported URL Formats

支持的URL格式

  • youtube.com/watch?v=VIDEO_ID
  • youtu.be/VIDEO_ID
  • youtube.com/embed/VIDEO_ID
  • youtube.com/v/VIDEO_ID
  • Bare video ID (11 characters)
  • youtube.com/watch?v=VIDEO_ID
  • youtu.be/VIDEO_ID
  • youtube.com/embed/VIDEO_ID
  • youtube.com/v/VIDEO_ID
  • 纯视频ID(11个字符)

Analysis Modes

分析模式

Select based on user request:
User SaysModeAction
"extract wisdom", "key insights"WisdomSee analysis-modes.md
"summarize", "TLDR", "overview"SummarySee analysis-modes.md
"questions", "Q&A", "discussion"Q&ASee analysis-modes.md
"quotes", "notable statements"QuotesUse
--with-segments
, see analysis-modes.md
Other specific requestsCustomApply user's instructions directly
根据用户请求选择对应模式:
用户需求模式操作
"提取见解"、"关键洞察"Wisdom(见解提取)查看analysis-modes.md
"总结"、"TLDR"、"概述"Summary(内容总结)查看analysis-modes.md
"问题准备"、"问答"、"讨论素材"Q&A(问答准备)查看analysis-modes.md
"语录"、"重要语句"Quotes(语录提取)使用
--with-segments
参数,查看analysis-modes.md
其他特定请求Custom(自定义分析)直接应用用户的指令

Error Handling

错误处理

The script returns partial results when possible:
  • Transcripts disabled: Returns metadata only, notes error
  • Private video: Clear error message with video ID
  • No transcript found: Returns metadata, suggests alternatives
  • Rate limiting: Retry after 30-60 seconds
Check the
errors
array in output for any issues.
脚本会尽可能返回部分结果:
  • 字幕已禁用:仅返回元数据,并标注错误
  • 私有视频:返回包含视频ID的清晰错误提示
  • 未找到字幕:返回元数据,并给出替代方案建议
  • 请求受限:30-60秒后重试
可查看输出中的
errors
数组了解具体问题。

Background Analysis (Subagent)

后台分析(子Agent)

For video analysis that shouldn't block the main conversation, spawn a background subagent:
Task(
  subagent_type: "general-purpose",
  prompt: "Read ~/.claude/skills/youtube-content/SKILL.md and follow the workflow.
    Analyze this YouTube video: {url}
    Mode: {wisdom|summary|qa|quotes}
    Save to knowledge base: {yes|no}"
)
对于不应阻塞主对话的视频分析任务,可启动后台子Agent:
Task(
  subagent_type: "general-purpose",
  prompt: "Read ~/.claude/skills/youtube-content/SKILL.md and follow the workflow.
    Analyze this YouTube video: {url}
    Mode: {wisdom|summary|qa|quotes}
    Save to knowledge base: {yes|no}"
)

Knowledge Persistence

知识持久化

Analyses and raw transcripts are automatically saved to a knowledge base for future reference.
分析结果和原始字幕文稿会自动保存到知识库,以便后续参考。

Configuration

配置

Set
CLAUDE_KNOWLEDGE_DIR
to customize storage location (default:
~/.claude/knowledge
).
设置
CLAUDE_KNOWLEDGE_DIR
可自定义存储位置(默认路径:
~/.claude/knowledge
)。

Save Analysis

保存分析结果

Saves both the analysis (markdown) and raw transcript (JSON):
bash
echo '{"video_id": "...", "metadata": {...}, "transcript": {...}, "analysis": "..."}' | \
  uv run scripts/save_analysis.py --mode wisdom --tags "ai,coding"
Output:
{"saved": true, "analysis_path": "...", "transcript_path": "..."}
同时保存分析结果(Markdown格式)和原始字幕文稿(JSON格式):
bash
echo '{"video_id": "...", "metadata": {...}, "transcript": {...}, "analysis": "..."}' | \
  uv run scripts/save_analysis.py --mode wisdom --tags "ai,coding"
输出:
{"saved": true, "analysis_path": "...", "transcript_path": "..."}

Search Knowledge

搜索知识库

bash
uv run scripts/search_knowledge.py --list          # List recent
uv run scripts/search_knowledge.py "react"         # Search keyword
uv run scripts/search_knowledge.py --tag ai        # Filter by tag
bash
uv run scripts/search_knowledge.py --list          # 列出最近的内容
uv run scripts/search_knowledge.py "react"         # 按关键词搜索
uv run scripts/search_knowledge.py --tag ai        # 按标签筛选

File Structure

文件结构

$CLAUDE_KNOWLEDGE_DIR/youtube/
├── .gitignore                  # Ignores transcripts/
├── index.md                    # Quick reference
├── analyses/
│   └── 2025-12-30_VIDEO_ID.md  # Formatted analysis with frontmatter
└── transcripts/                # Raw data (gitignored)
    └── 2025-12-30_VIDEO_ID.json # Full fetch output with transcript
Note: Raw transcripts are gitignored by default as they can be large and re-fetched from YouTube if needed.
$CLAUDE_KNOWLEDGE_DIR/youtube/
├── .gitignore                  # 忽略transcripts/目录
├── index.md                    # 快速参考文档
├── analyses/
│   └── 2025-12-30_VIDEO_ID.md  # 带前置信息的格式化分析结果
└── transcripts/                # 原始数据(已加入git忽略)
    └── 2025-12-30_VIDEO_ID.json # 包含字幕的完整获取输出
注意:原始字幕文稿默认被加入git忽略,因为它们可能体积较大,且可随时从YouTube重新获取。