# YouTube 内容工具
当用户分享 YouTube 链接或视频链接、要求总结视频、索取字幕文本,或希望从任何 YouTube 视频中提取并重新整理内容时使用。将字幕转换为结构化内容(章节、摘要、帖子、博客文章)。
从 YouTube 视频中提取字幕并将其转换为有用的格式。
pip install youtube-transcript-api
SKILL_DIR 是包含本 SKILL.md 文件的目录。该脚本接受任何标准 YouTube URL 格式、短链接(youtu.be)、Shorts、嵌入、直播链接,或原始的 11 位视频 ID。
# JSON output with metadata
python3 SKILL_DIR/scripts/fetch_transcript.py "https://youtube.com/watch?v=VIDEO_ID"
# Plain text (good for piping into further processing)
python3 SKILL_DIR/scripts/fetch_transcript.py "URL" --text-only
# With timestamps
python3 SKILL_DIR/scripts/fetch_transcript.py "URL" --timestamps
# Specific language with fallback chain
python3 SKILL_DIR/scripts/fetch_transcript.py "URL" --language tr,en
获取字幕之后,根据用户的请求进行格式化:
00:00 Introduction — host opens with the problem statement
03:45 Background — prior work and why existing solutions fall short
12:20 Core method — walkthrough of the proposed approach
24:10 Results — benchmark comparisons and key takeaways
31:55 Q&A — audience questions on scalability and next steps
--text-only --timestamps 参数获取字幕。--language 重试以获取任何可用字幕。若仍为空,告知用户该视频可能已禁用字幕。--language 重试以获取任何可用字幕,然后向用户说明实际语言。pip install youtube-transcript-api 后重试。
评论区