youtube-transcript-cn
YouTube 字幕提取技能
从 YouTube 视频提取字幕,输出中文文字稿。
快速使用
python3 scripts/get_transcript.py "https://www.youtube.com/watch?v=VIDEO_ID"
工作流程
- 获取视频链接:从用户消息中提取 YouTube URL
- 运行脚本:执行
scripts/get_transcript.py提取字幕 - 处理输出:
- 如果字幕是中文:直接输出
- 如果字幕是英文:翻译为中文后输出
- 保存结果:根据用户需求保存为 Markdown 文件
脚本参数
| 参数 | 说明 | 默认值 |
|---|---|---|
url |
YouTube 视频链接或 ID | 必填 |
-f, --format |
输出格式: text, markdown, json |
markdown |
-t, --timestamps |
包含时间戳 | 否 |
-l, --lang |
首选语言(逗号分隔) | zh,en |
-o, --output |
输出文件路径 | stdout |
使用示例
基本用法
python3 scripts/get_transcript.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
带时间戳输出
python3 scripts/get_transcript.py -t "https://youtu.be/VIDEO_ID"
保存到文件
python3 scripts/get_transcript.py -o output.md "https://www.youtube.com/watch?v=VIDEO_ID"
JSON 格式(便于后处理)
python3 scripts/get_transcript.py -f json "VIDEO_ID"
支持的 URL 格式
https://www.youtube.com/watch?v=VIDEO_IDhttps://youtu.be/VIDEO_IDhttps://www.youtube.com/embed/VIDEO_ID- 直接使用 Video ID
语言优先级
脚本按以下顺序查找字幕:
- 简体中文 (zh-Hans)
- 繁体中文 (zh-Hant)
- 中文 (zh)
- 英文 (en)
- 自动生成字幕
翻译处理
如果获取到的是英文字幕,需要翻译为中文:
- 运行脚本获取英文字幕
- 使用 Claude 内置能力翻译为流畅的中文
- 保持原文结构和段落划分
错误处理
| 错误 | 原因 | 解决方案 |
|---|---|---|
| No captions available | 视频无字幕 | 告知用户该视频没有可用字幕 |
| Cannot extract video ID | URL 格式错误 | 请求用户提供正确的 YouTube 链接 |
| 网络超时 | 网络问题 | 重试或检查网络连接 |
输出格式示例
Markdown 格式
# 视频标题
- **Video ID**: abc123
- **语言**: 中文(自动生成)
- **链接**: https://www.youtube.com/watch?v=abc123
---
## 文字稿
这是视频的第一段内容...
这是视频的第二段内容...
More from zephyrwang6/myskill
web-scraper
Fetch and extract content from web pages, converting HTML to clean markdown. Use when users want to read web articles, extract information from URLs, scrape web content, or when the built-in WebFetch tool fails due to network restrictions. Trigger when user provides URLs to read, asks to fetch web content, or needs to extract text from websites.
246rss-aggregator
Aggregates and summarizes recent updates from a predefined list of RSS feeds. Use when the user asks for "recent updates", "what's new", or "RSS updates" within a specific timeframe.
196content-topic-generator
从文章、推文、社交媒体内容生成多角度选题,包括推文选题(140字完整内容)和公众号选题(含详细大纲)。支持延伸、反驳、扩充、热点结合四种策略。当用户需要基于现有内容创作新选题、分析文章生成衍生内容、或进行内容再创作时使用。适用场景:(1) 分析推文/文章并生成选题,(2) 创建公众号/社交媒体内容策划,(3) 将长文拆解为多个传播点,(4) 内容营销和话题策划。
99topic-collector
AI热点采集工具。从Twitter/X、Product Hunt、Reddit、Hacker News、博客等采集AI相关热点内容。当用户说"开始今日选题"、"采集热点"、"看看今天有什么新闻"、"今日AI热点"时触发。聚焦领域:Vibe Coding、Claude Skill、AI知识管理、AI模型更新、AI新产品、海外热点。
76topic-generator
AI选题生成工具。从采集的热点中筛选TOP10,生成完整选题方案。当用户说"生成选题"、"筛选热点"、"哪些值得写"时触发。输出包含:事件描述、核心角度、标题、写作方式。
71web-article-translator
翻译在线文章为中文并保存为 Markdown 格式。当用户需要翻译网页文章、博客文章时使用此技能,例如:"翻译这篇文章 https://example.com/article"、"把这个 URL 的文章翻译成中文并保存"。
50