Video and audio downloads
Access progressive and adaptive streams, choose resolutions, download audio tracks and merge streams with FFmpeg when needed.
A powerful Python library and command line tool for downloading videos, audio, playlists and more. Simple to use. Built for developers.
Everything you need to interact with YouTube content, whether you're building a Python application or working directly from your terminal.
Access progressive and adaptive streams, choose resolutions, download audio tracks and merge streams with FFmpeg when needed.
Work with entire playlists and channels, control download limits and manage collections.
Search for videos and integrate results directly into your download workflow.
Retrieve available caption tracks and export subtitles in SRT format.
Select original audio or alternative language tracks when available.
Use pytubefix directly from your terminal. Supports commands, options, pipelines, standard output, error handling and exit codes.
An asynchronous API and OAuth support for compatible restricted-content workflows.
Install pytubefix and start working with YouTube content using a straightforward Python interface.
from pytubefix import YouTube from pytubefix.cli import on_progress yt = YouTube( url, on_progress_callback=on_progress ) print(yt.title) yt.streams.get_highest_resolution().download()
from pytubefix import YouTube from pytubefix.cli import on_progress yt = YouTube( url, on_progress_callback=on_progress ) yt.streams.get_audio_only().download()
from pytubefix import Playlist playlist = Playlist(url) for video in playlist.videos: video.streams.get_audio_only().download()
A command line experience designed for developers who value automation, composability and Unix conventions.
# Download a video $ pytubefix "https://www.youtube.com/watch?v=VIDEO" # Download audio in Portuguese $ pytubefix -a --audio-track pt URL # Download a playlist $ pytubefix playlist -a -n 10 PLxxxx -o music/ # List available streams $ pytubefix streams URL # Export captions $ pytubefix captions URL -c en > subtitles.srt # Search and pipe results into downloads $ pytubefix search "lofi" -n 3 | cut -f1 | pytubefix -a - -o music/
$ pytubefix playlist -a PLxxxx [1/3] First song ↳ |████████████████████| 100% [2/3] Second song ↳ |████████████████████| 100% [3/3] Third song ↳ |██████████░░░░░░░░░░| 52.1% $ echo $? 0 # Exit status # 0 Success # 1 Error # 2 Usage error # 130 Interrupted
Follow the latest stable release or explore the newest tagged version of pytubefix.
pip install -U pytubefix
pip install --pre -U pytubefix
Explore the source, report issues or contribute to the pytubefix project.