{"id":"youtube-transcribe-skill","name":"youtube-transcribe-skill","summary":"YouTube動画から字幕や書き起こしを抽出してください。トリガー:「youtubeトランスクリプト」、「字幕の抽出」、「動画字幕」、「视频字幕」、「字幕提取」、「YouTube转文字」、「提取字幕」。","body":"# YouTube Transcript Extraction\n\nExtract subtitles/transcripts from a YouTube video URL and save them as a local file.\n\nInput YouTube URL: $ARGUMENTS\n\n## Step 1: Verify URL\n\nConfirm the input is a valid YouTube URL (supports `youtube.com/watch?v=`, `youtu.be/`, and `youtube.com/shorts/` formats). If no URL is provided via arguments, check the conversation context for a YouTube link.\n\n## Step 2: CLI Quick Extraction (Priority Attempt)\n\nUse command-line tools to quickly extract subtitles.\n\n### 2.1 Check Tool Availability\n\nExecute `which yt-dlp`.\n\n- If `yt-dlp` is **found**, proceed to 2.2.\n- If `yt-dlp` is **not found**, skip to **Step 3**.\n\n### 2.2 Get Video Title\n\n```bash\nyt-dlp --cookies-from-browser=chrome --get-title \"[VIDEO_URL]\"\n```\n\n- **Tip**: Always add `--cookies-from-browser` to avoid sign-in restrictions. Default to `chrome`.\n- If it 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.\n\n### 2.3 Download Subtitles\n\n```bash\nyt-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]\"\n```\n\n### 2.4 Convert to Plain Text\n\n`yt-dlp` saves subtitles as `.vtt` or `.srt` files. Convert the downloaded file to plain `Timestamp Text` format:\n\n1. Read the downloaded subtitle file (`.vtt` or `.srt`).\n2. Strip VTT/SRT headers, styling tags, and duplicate lines.\n3. Save as `<Video Title>.txt` with one `Timestamp Text` entry per line.\n\n### 2.5 Verify Results\n\n- **Exit code 0**: Convert and save the subtitle file, then report completion.\n- **Exit code non-0**:\n  - If error is related to browser/cookies, ask user for correct browser and retry.\n  - If other errors (e.g., video unavailable), proceed to **Step 3**.\n\n## Step 3: Browser Automation (Fallback)\n\nWhen the CLI method fails or `yt-dlp` is missing, use Chrome DevTools MCP to extract subtitles via browser UI automation.\n\n### 3.1 Check Tool Availability\n\nCheck if Chrome DevTools MCP tools are available (look for tools matching `chrome__new_page` or similar).\n\nIf Chrome DevTools MCP is **not** available and `yt-dlp` was **not** found in Step 2, stop and notify the user: \"Unable to proceed. Please either install `yt-dlp` (for fast CLI extraction) or configure Chrome DevTools MCP (for browser automation).\"\n\n### 3.2 Open Video Page\n\nUse Chrome DevTools MCP `new_page` to open the video URL.\n\n### 3.3 Analyze Page State\n\nUse Chrome DevTools MCP `take_snapshot` to read the page accessibility tree.\n\n### 3.4 Expand Video Description\n\nThe \"Show transcript\" button is usually hidden within the collapsed description area.\n\n1. Search the snapshot for a button labeled **\"...more\"**, **\"...更多\"**, or **\"Show more\"** (in the description block below the video title).\n2. Use Chrome DevTools MCP `click` to click that button.\n\n### 3.5 Open Transcript Panel\n\n1. Use Chrome DevTools MCP `take_snapshot` to get the updated UI.\n2. Search for a button labeled **\"Show transcript\"**, **\"显示转录稿\"**, or **\"内容转文字\"**.\n3. Use Chrome DevTools MCP `click` to click that button.\n4. If the button is not found, the video may not have a transcript available — notify the user and stop.\n\n### 3.6 Extract Content via DOM\n\nDirectly reading the accessibility tree for long transcript lists is slow and token-heavy. Use Chrome DevTools MCP `evaluate_script` to run this JavaScript instead:\n\n```javascript\n() => {\n  const segments = document.querySelectorAll(\"ytd-transcript-segment-renderer\");\n  if (!segments.length) return \"BUFFERING\";\n  return Array.from(segments)\n    .map((seg) => {\n      const time = seg.querySelector(\".segment-timestamp\")?.innerText.trim();\n      const text = seg.querySelector(\".segment-text\")?.innerText.trim();\n      return `${time} ${text}`;\n    })\n    .join(\"\\n\");\n};\n```\n\nIf it returns `\"BUFFERING\"`, wait a few seconds and retry (up to 3 attempts).\n\n### 3.7 Save and Cleanup\n\n1. Save the extracted text as `<Video Title>.txt`.\n2. Use Chrome DevTools MCP `close_page` to release resources.\n\n## Output Requirements\n\n- Save the subtitle file to the current working directory.\n- Filename format: `<Video Title>.txt`\n- File content format: Each line should be `Timestamp Subtitle Text`.\n- Report upon completion: file path, subtitle language, and total number of lines.","author":"@feiskyer","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/feiskyer/claude-code-settings/tree/main/skills/youtube-transcribe-skill","license":"MIT","category":"writing","lang":"en","tokens":1104,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}