YouTube Transcript Extract transcripts from YouTube videos using the youtube-transcript-api. Usage Run the script with a YouTube URL or video ID: With timestamps: Defaults - Without timestamps (default): Plain text, one line per caption segment - With timestamps : format (or for longer videos) Supported URL Formats - - - - Raw video ID (11 characters) Output - CRITICAL: YOU MUST NEVER MODIFY THE RETURNED TRANSCRIPT - If the transcript is without timestamps, you SHOULD clean it up so that it is arranged by complete paragraphs and the lines don't cut in the middle of sentences. - If you were as…

\n ]\n for pattern in patterns:\n match = re.search(pattern, url_or_id)\n if match:\n return match.group(1)\n raise ValueError(f\"Could not extract video ID from: {url_or_id}\")\n\n\ndef format_timestamp(seconds: float) -> str:\n \"\"\"Convert seconds to HH:MM:SS or MM:SS format.\"\"\"\n hours = int(seconds // 3600)\n minutes = int((seconds % 3600) // 60)\n secs = int(seconds % 60)\n if hours > 0:\n return f\"{hours:02d}:{minutes:02d}:{secs:02d}\"\n return f\"{minutes:02d}:{secs:02d}\"\n\n\ndef get_transcript(video_id: str, with_timestamps: bool = False) -> str:\n \"\"\"Fetch and format transcript for a YouTube video.\"\"\"\n api = YouTubeTranscriptApi()\n transcript = api.fetch(video_id)\n \n if with_timestamps:\n lines = [f\"[{format_timestamp(snippet.start)}] {snippet.text}\" for snippet in transcript.snippets]\n else:\n lines = [snippet.text for snippet in transcript.snippets]\n \n return '\\n'.join(lines)\n\n\ndef main():\n parser = argparse.ArgumentParser(description='Get YouTube video transcript')\n parser.add_argument('video', help='YouTube video URL or video ID')\n parser.add_argument('--timestamps', '-t', action='store_true', \n help='Include timestamps in output')\n args = parser.parse_args()\n \n try:\n video_id = extract_video_id(args.video)\n transcript = get_transcript(video_id, with_timestamps=args.timestamps)\n print(transcript)\n except Exception as e:\n print(f\"Error: {e}\", file=sys.stderr)\n sys.exit(1)\n\n\nif __name__ == '__main__':\n main()\n","content_type":"text/x-python; charset=utf-8","language":"python","size":2246,"content_sha256":"795f434209337339f1dda518a1018727d5fdd98ea265b0962bbec93edb7fc505"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"YouTube Transcript","type":"text"}]},{"type":"paragraph","content":[{"text":"Extract transcripts from YouTube videos using the youtube-transcript-api.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Usage","type":"text"}]},{"type":"paragraph","content":[{"text":"Run the script with a YouTube URL or video ID:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"uv run scripts/get_transcript.py \"VIDEO_URL_OR_ID\"","type":"text"}]},{"type":"paragraph","content":[{"text":"With timestamps:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"uv run scripts/get_transcript.py \"VIDEO_URL_OR_ID\" --timestamps","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Defaults","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Without timestamps","type":"text","marks":[{"type":"strong"}]},{"text":" (default): Plain text, one line per caption segment","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"With timestamps","type":"text","marks":[{"type":"strong"}]},{"text":": ","type":"text"},{"text":"[MM:SS] text","type":"text","marks":[{"type":"code_inline"}]},{"text":" format (or ","type":"text"},{"text":"[HH:MM:SS]","type":"text","marks":[{"type":"code_inline"}]},{"text":" for longer videos)","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Supported URL Formats","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"https://www.youtube.com/watch?v=VIDEO_ID","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"https://youtu.be/VIDEO_ID","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"https://youtube.com/embed/VIDEO_ID","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Raw video ID (11 characters)","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Output","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"CRITICAL: YOU MUST NEVER MODIFY THE RETURNED TRANSCRIPT","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"If the transcript is without timestamps, you SHOULD clean it up so that it is arranged by complete paragraphs and the lines don't cut in the middle of sentences.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"If you were asked to save the transcript to a specific file, save it to the requested file.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"If no output file was specified, use the YouTube video ID with a ","type":"text"},{"text":"-transcript.txt","type":"text","marks":[{"type":"code_inline"}]},{"text":" suffix.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Notes","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Fetches auto-generated or manually added captions (whichever is available)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Requires the video to have captions enabled","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Falls back to auto-generated captions if manual ones aren't available","type":"text"}]}]}]},{"type":"hr","attrs":{"markup":"---"}}]},"metadata":{"date":"2026-06-05","name":"youtube-transcript","author":"@skillopedia","source":{"stars":267,"repo_name":"agent-skills","origin_url":"https://github.com/intellectronica/agent-skills/blob/HEAD/skills/youtube-transcript/SKILL.md","repo_owner":"intellectronica","body_sha256":"2ab830a031b3fe36b9dde9d57f91771200faebab29685cfd0fff17d09d7deb4e","cluster_key":"43e69bea303b951f094e142f6a8aab2cd633339a5e29752b2608b55964489552","clean_bundle":{"format":"clean-skill-bundle-v1","source":"intellectronica/agent-skills/skills/youtube-transcript/SKILL.md","attachments":[{"id":"8b921401-9250-56f6-84f1-1df4716adba8","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/8b921401-9250-56f6-84f1-1df4716adba8/attachment.py","path":"scripts/get_transcript.py","size":2246,"sha256":"795f434209337339f1dda518a1018727d5fdd98ea265b0962bbec93edb7fc505","contentType":"text/x-python; charset=utf-8"}],"bundle_sha256":"211478c25382ad0c1d7e1c2a417d91e981465c592789ed60c8c063383e402bac","attachment_count":1,"text_attachments":1,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":3,"skill_md_path":"skills/youtube-transcript/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"media-content","category_label":"Media"},"exact_dupes_collapsed_into_this":2},"version":"v1","category":"media-content","import_tag":"clean-skills-v1","description":"Extract transcripts from YouTube videos. Use when the user asks for a transcript, subtitles, or captions of a YouTube video and provides a YouTube URL (youtube.com/watch?v=, youtu.be/, or similar). Supports output with or without timestamps."}},"renderedAt":1782979610388}

YouTube Transcript Extract transcripts from YouTube videos using the youtube-transcript-api. Usage Run the script with a YouTube URL or video ID: With timestamps: Defaults - Without timestamps (default): Plain text, one line per caption segment - With timestamps : format (or for longer videos) Supported URL Formats - - - - Raw video ID (11 characters) Output - CRITICAL: YOU MUST NEVER MODIFY THE RETURNED TRANSCRIPT - If the transcript is without timestamps, you SHOULD clean it up so that it is arranged by complete paragraphs and the lines don't cut in the middle of sentences. - If you were as…