‹ 首页

youtube-transcribe-skill

@feiskyer · 收录于 1 周前

Extract subtitles/transcripts from a YouTube video URL and save as a local file. Use when you need to extract subtitles from a YouTube video.

适合你,如果需要从YouTube视频中获取文字版内容

/ 下载安装
youtube-transcribe-skill.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add feiskyer/codex-settings/youtube-transcribe-skill
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- feiskyer/codex-settings/youtube-transcribe-skill
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify feiskyer/codex-settings/youtube-transcribe-skill
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
215GitHub stars
~1K上下文体积 · 单文件
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 06025f6

YouTube Transcript Extraction

Extract subtitles/transcripts from a YouTube video URL and save them as a local file.

Input YouTube URL: $ARGUMENTS

Step 1: Verify URL and Get Video Information
  1. Verify URL Format: Confirm the input is a valid YouTube URL (supports youtube.com/watch?v= or youtu.be/ formats).
  1. Get Video Information:
  2. If yt-dlp is available, prefer yt-dlp --get-title "[VIDEO_URL]".
  3. If using browser automation, extract the title from the page (via snapshot or document.title) for file naming.
Step 2: CLI Quick Extraction (Priority Attempt)

Use command-line tools to quickly extract subtitles.

  1. Check Tool Availability: Execute which yt-dlp.
  • If yt-dlp is found, proceed to subtitle download.
  • If yt-dlp is NOT found, skip immediately to Step 3.
  1. Execute Subtitle Download (Only if yt-dlp is found):
  • Tip: Always add --cookies-from-browser to avoid sign-in restrictions. Default to chrome.
  • Retry Logic: If yt-dlp fails with a browser error (e.g., "Could not open Chrome"), ask the user to specify their available browser (e.g., firefox, safari, edge) and retry.

```bash # Get the title first (try chrome first) yt-dlp --cookies-from-browser=chrome --get-title "[VIDEO_URL]"

# Download subtitles yt-dlp --cookies-from-browser=chrome --write-auto-sub --write-sub --sub-lang zh-Hans,zh-Hant,en --skip-download --output "<Video Title>.%(ext)s" "[VIDEO_URL]" ```

  1. Verify Results:
  2. Check the command exit code.
  3. Exit code 0 (Success): Subtitles have been saved locally, task complete.
  4. Exit code non-0 (Failure):
  5. If error is related to browser/cookies, ask user for correct browser and retry Step 2.
  6. If other errors (e.g., video unavailable), proceed to Step 3.
Step 3: Browser Automation (Fallback)

When the CLI method fails or yt-dlp is missing, use browser UI automation to extract subtitles.

  1. Check Tool Availability:
  • Check if chrome-devtools-mcp tools (specifically mcp__chrome__new_page) are available.
  • CRITICAL CHECK: If chrome-devtools-mcp is NOT available AND yt-dlp was NOT found in Step 2:
  • STOP execution.
  • Notify the User: "Unable to proceed. Please either install yt-dlp (for fast CLI extraction) OR configure chrome-devtools-mcp (for browser automation)."
  1. Initialize Browser Session (If tools are available):

Call mcp__chrome__new_page to open the video URL.

3.2 Analyze Page State

Call mcp__chrome__take_snapshot to read the page accessibility tree.

3.3 Expand Video Description

_Reason: The "Show transcript" button is usually hidden within the collapsed description area._

  1. Search the snapshot for a button labeled "...more", "...更多", or "Show more" (usually located in the description block below the video title).
  2. Call mcp__chrome__click to click that button.
3.4 Open Transcript Panel
  1. Call mcp__chrome__take_snapshot to get the updated UI snapshot.
  2. Search for a button labeled "Show transcript", "显示转录稿", or "内容转文字".
  3. Call mcp__chrome__click to click that button.
3.5 Extract Content via DOM

_Reason: Directly reading the accessibility tree for long lists is slow and consumes many tokens; DOM injection is more efficient._

Call mcp__chrome__evaluate_script to execute the following JavaScript:

() => {
  // Select all transcript segment containers
  const segments = document.querySelectorAll("ytd-transcript-segment-renderer");
  if (!segments.length) return "BUFFERING"; // Retry if empty

  // Iterate and format as "timestamp text"
  return Array.from(segments)
    .map((seg) => {
      const time = seg.querySelector(".segment-timestamp")?.innerText.trim();
      const text = seg.querySelector(".segment-text")?.innerText.trim();
      return `${time} ${text}`;
    })
    .join("\n");
};

If it returns "BUFFERING", wait a few seconds and retry.

3.6 Save and Cleanup
  1. Use the Write tool to save the extracted text as a local file (e.g., <Video Title>.txt).
  2. Call mcp__chrome__close_page to release resources.
Output Requirements
  • Save the subtitle file to the current working directory.
  • Filename format: <Video Title>.txt
  • File content format: Each line should be Timestamp Subtitle Text.
  • Report upon completion: File path, subtitle language, total number of lines.
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。