{"id":8567,"library":"pytubefix","title":"pytubefix","description":"Python3 library for downloading YouTube Videos. Current version is 10.3.8. It's a lightweight, Pythonic, dependency-free, library (and command-line utility) for downloading YouTube Videos. pytubefix is an actively maintained fork of pytube that solves broken functionality and adds new features, regularly addressing YouTube's continuous changes. It supports progressive and DASH streams, callback functions for download progress, and caption extraction.","status":"active","version":"10.3.8","language":"en","source_language":"en","source_url":"https://github.com/juanbindez/pytubefix","tags":["youtube","video-downloader","audio-downloader","playlist-downloader","captions","cli","async"],"install":[{"cmd":"pip install pytubefix","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Required for automatic PO Token generation, which helps bypass bot detection and some age restrictions. The library attempts to locate `node` in the system PATH.","package":"nodejs","optional":true}],"imports":[{"symbol":"YouTube","correct":"from pytubefix import YouTube"},{"symbol":"Playlist","correct":"from pytubefix import Playlist"},{"symbol":"Search","correct":"from pytubefix import Search"},{"symbol":"on_progress","correct":"from pytubefix.cli import on_progress"},{"symbol":"VideoUnavailable","correct":"from pytubefix.exceptions import VideoUnavailable"}],"quickstart":{"code":"import os\nfrom pytubefix import YouTube\n\ndef on_progress(stream, chunk, bytes_remaining):\n    total_size = stream.filesize\n    bytes_downloaded = total_size - bytes_remaining\n    percentage_of_completion = bytes_downloaded / total_size * 100\n    print(f\"\\rDownloading: {percentage_of_completion:.2f}%\", end='')\n\nvideo_url = os.environ.get('YOUTUBE_VIDEO_URL', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ') # Rick Astley - Never Gonna Give You Up\n\ntry:\n    yt = YouTube(video_url, on_progress_callback=on_progress)\n    print(f\"\\nTitle: {yt.title}\")\n    print(f\"Author: {yt.author}\")\n    print(f\"Views: {yt.views}\")\n\n    # Get the highest resolution progressive stream\n    # Progressive streams contain both video and audio\n    stream = yt.streams.get_highest_resolution()\n    if stream:\n        print(f\"Downloading '{yt.title}' in {stream.resolution}...\")\n        stream.download(output_path='./downloads')\n        print(\"\\nDownload complete!\")\n    else:\n        print(\"No suitable progressive stream found.\")\n\nexcept Exception as e:\n    print(f\"\\nAn error occurred: {e}\")","lang":"python","description":"This quickstart example demonstrates how to download a YouTube video using `pytubefix`. It initializes a `YouTube` object with a video URL, registers a progress callback for real-time updates, retrieves the video's metadata, and then downloads the highest resolution progressive stream to a 'downloads' directory. It handles a placeholder URL and basic error reporting."},"warnings":[{"fix":"Regularly update `pytubefix` to the latest version (`pip install --upgrade pytubefix`) to receive patches for YouTube's API changes. Wrap download operations in `try-except` blocks for graceful error handling.","message":"YouTube's internal APIs change frequently, which can cause `pytubefix` functionality to break without warning. While `pytubefix` is actively maintained, users should expect occasional disruptions.","severity":"breaking","affected_versions":"All versions, due to external API changes"},{"fix":"When creating a `YouTube` object, set `use_oauth=True` and `allow_oauth_cache=True` to authenticate and cache tokens, reducing repeated prompts. `yt = YouTube(url, use_oauth=True, allow_oauth_cache=True)`.","message":"Accessing age-restricted content or private videos often requires OAuth authentication. If `allow_oauth_cache=False` (default for some operations), you may be prompted repeatedly for authentication.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wait until the live stream has ended, sometimes several hours or days, before attempting to download. Implement specific exception handling for `LiveStreamEnded` or `VideoUnavailable`.","message":"Live streams typically cannot be downloaded until after they have concluded. Trying to download an active or recently finished live stream may result in errors or `LiveStreamEnded` exceptions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `pytubefix` version 10.3.3 or newer to resolve issues where `title`, `duration`, or `length` might be incorrectly retrieved or raise `TypeError`. (`pip install --upgrade pytubefix`)","message":"Older versions (prior to v10.1.1 and v10.3.3) could encounter `TypeError` when accessing attributes like `.length` or find `yt.title` and `yt.duration` as bound methods instead of properties.","severity":"breaking","affected_versions":"<10.1.1, <10.3.3"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify the video URL is correct and the video is publicly accessible. Try updating `pytubefix` (`pip install --upgrade pytubefix`). For region-locked content, consider using proxies. Wrap calls in `try-except VideoUnavailable` for graceful handling.","cause":"The video is private, deleted, region-locked, or YouTube's API structure changed, preventing `pytubefix` from accessing it.","error":"pytubefix.exceptions.VideoUnavailable: {video_id} is unavailable"},{"fix":"Update `pytubefix` to the latest version (`pip install --upgrade pytubefix`). This error frequently indicates that a new patch has been released to accommodate YouTube's changes.","cause":"YouTube has changed its internal API, rendering the current parsing logic in `pytubefix` obsolete for that specific video or stream. Often happens when YouTube deprecates old stream manifest formats.","error":"HTTP Error 410: Gone"},{"fix":"Instantiate `YouTube` with OAuth enabled: `yt = YouTube(url, use_oauth=True, allow_oauth_cache=True)`. This will prompt for browser authentication and cache the token.","cause":"Attempting to download an age-restricted video without providing OAuth credentials.","error":"pytubefix.exceptions.AgeRestrictedError: {video_id} is age restricted, and can't be accessed without logging in."},{"fix":"This typically requires a `pytubefix` library update. Install the latest version (`pip install --upgrade pytubefix`) to get the fix for the changed dictionary keys.","cause":"YouTube frequently changes the keys in its JSON responses for video metadata, causing `pytubefix` to fail when parsing the data.","error":"KeyError: 'videoDetails' or other dictionary key"}]}