{"library":"youtube-transcript-api","code":"from youtube_transcript_api import YouTubeTranscriptApi, NoTranscriptFound, TranscriptsDisabled, IpBlocked\n\nvideo_id = \"_dQ8wY76uI8\" # Example: 'Never Gonna Give You Up' by Rick Astley\n\ntry:\n    # Instantiate the API client\n    ytt_api = YouTubeTranscriptApi()\n\n    # Fetch the transcript for the video\n    # By default, it attempts to get English. You can specify languages=['de', 'en'] for priority.\n    transcript = ytt_api.fetch(video_id)\n\n    # Print the full transcript text\n    full_text = \" \".join([item['text'] for item in transcript])\n    print(f\"Transcript for video ID {video_id}:\\n{full_text[:500]}...\")\n\n    # You can also list available transcripts and their languages\n    # transcript_list = ytt_api.list_transcripts(video_id)\n    # for t in transcript_list:\n    #     print(f\"Available transcript: {t.language} ({'generated' if t.is_generated else 'manual'})\")\n\nexcept NoTranscriptFound:\n    print(f\"No transcript found for video ID: {video_id}\")\nexcept TranscriptsDisabled:\n    print(f\"Transcripts are disabled for video ID: {video_id}\")\nexcept IpBlocked:\n    print(f\"Your IP was blocked by YouTube. Consider using a proxy.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to fetch a transcript for a given YouTube video ID using the `YouTubeTranscriptApi` client. It includes error handling for common issues like missing or disabled transcripts and IP blocking. The example retrieves the 'Never Gonna Give You Up' transcript and prints its beginning.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}