--- name: youtube-transcribe-skill description: 'Extract subtitles/transcripts from YouTube videos. Triggers: "youtube transcript", "extract subtitles", "video captions", "视频字幕", "字幕提取", "YouTube转文字", "提取字幕".' --- # 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 Confirm 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. ## Step 2: CLI Quick Extraction (Priority Attempt) Use command-line tools to quickly extract subtitles. ### 2.1 Check Tool Availability Execute `which yt-dlp`. - If `yt-dlp` is **found**, proceed to 2.2. - If `yt-dlp` is **not found**, skip to **Step 3**. ### 2.2 Get Video Title ```bash yt-dlp --cookies-from-browser=chrome --get-title "[VIDEO_URL]" ``` - **Tip**: Always add `--cookies-from-browser` to avoid sign-in restrictions. Default to `chrome`. - 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. ### 2.3 Download Subtitles ```bash yt-dlp --cookies-from-browser=chrome --write-auto-sub --write-sub --sub-lang zh-Hans,zh-Hant,en --skip-download --output "