{"id":2248,"library":"pytube","title":"Pytube YouTube Downloader","description":"Pytube is a Python 3 library designed for downloading YouTube videos and playlists. It handles various resolutions, formats, and audio-only extractions. Currently at version 15.0.0, it maintains an active release cadence, primarily updating to adapt to frequent changes in YouTube's frontend, which it scrapes to function.","status":"active","version":"15.0.0","language":"en","source_language":"en","source_url":"https://github.com/pytube/pytube","tags":["youtube","download","video","scraper"],"install":[{"cmd":"pip install pytube","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"YouTube","correct":"from pytube import YouTube"},{"symbol":"Playlist","correct":"from pytube import Playlist"},{"symbol":"Search","correct":"from pytube import Search"}],"quickstart":{"code":"from pytube import YouTube\n\n# Example: Download the highest resolution of a video\nvideo_url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' # Rick Astley - Never Gonna Give You Up\n\ntry:\n    yt = YouTube(video_url)\n    print(f\"Downloading: {yt.title}...\")\n    \n    # Get the highest resolution stream\n    stream = yt.streams.get_highest_resolution()\n    \n    # Or, filter by resolution and file extension\n    # stream = yt.streams.filter(res=\"720p\", file_extension='mp4').first()\n\n    if stream:\n        stream.download(output_path='./downloads')\n        print(f\"Successfully downloaded '{yt.title}' to ./downloads\")\n    else:\n        print(\"No suitable stream found.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize a YouTube object with a video URL and download the highest resolution stream to a local 'downloads' directory. It includes basic error handling."},"warnings":[{"fix":"Update `pytube` to the latest version immediately if you encounter download failures or errors. Check the GitHub repository for recent issues or workarounds.","message":"Pytube relies on scraping YouTube's frontend, making it highly susceptible to breaking changes when YouTube updates its site. This often manifests as `KeyError`, `RegexMatchError`, `HTTPError` (404, 403), or `AgeRestrictedError`.","severity":"breaking","affected_versions":"All versions are vulnerable to future YouTube updates. Specific patches are released frequently."},{"fix":"If you need to download age-restricted content, you must implement an OAuth flow (using `pytube.request.get_auth_gmt()`) to obtain necessary cookies for authentication. Refer to the `pytube` documentation for authentication examples.","message":"Since version 11.0.0, downloading age-restricted videos explicitly requires user authentication. Attempts to download without authentication will raise an `AgeRestrictedError`.","severity":"breaking","affected_versions":">= 11.0.0"},{"fix":"Ensure the URL points to a non-live video. There is no built-in `pytube` mechanism to download ongoing live streams.","message":"Pytube does not support downloading live streams. As of version 10.8.3, attempts to process a livestream URL will raise an exception (e.g., `LiveStreamError`).","severity":"gotcha","affected_versions":">= 10.8.3"},{"fix":"If download speeds are unusually slow or downloads fail, update `pytube` to the latest version. This issue is usually addressed quickly by the maintainers.","message":"YouTube occasionally implements download throttling mechanisms by obfuscating URL parameters (e.g., the 'n' cipher). While `pytube` actively releases updates to bypass this (e.g., v10.9.0), issues can recur.","severity":"gotcha","affected_versions":"Intermittent across all versions, typically fixed in subsequent releases."}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}