Skip to main content

<a href="#"><img src="https://assets.nickficano.com/gh-pytube.min.svg" width="456" height="143" alt="pytube logo" /></a>

<a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/dm/pytube?style=flat-square" alt="pypi"/></a>

<a href="https://pytube.io/en/latest/"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest&style=flat-square" /></a>

<a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/v/pytube?style=flat-square" /></a>

Actively soliciting contributors!

Have ideas for how pytube can be improved? Feel free to open an issue or a pull request!

pytube

pytube is a genuine, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube videos.

Documentation

Detailed documentation about the usage of the library can be found at pytube.io. This is recommended for most cases. If you want to hastily download a single video, the quick start guide below might be what you're looking for.

Description

YouTube is the most popular video-sharing platform in the world and as a hacker, you may encounter a situation where you want to script something to download videos. For this, I present to you: pytube.

pytube is a lightweight library written in Python. It has no third-party

dependencies and aims to be highly reliable.

pytube also makes pipelining easy, allowing you to specify callback functions for different download events, such as on progress or on complete.

Furthermore, pytube includes a command-line utility, allowing you to download videos right from the terminal.

Features

  • Support for both progressive & DASH streams

  • Support for downloading the complete playlist

  • Easily register on_download_progress & on_download_complete callbacks

  • Command-line interfaced included

  • Caption track support

  • Outputs caption tracks to .srt format (SubRip Subtitle)

  • Ability to capture thumbnail URL

  • Extensively documented source code

  • No third-party dependencies

Quickstart

This guide covers the most basic usage of the library. For more detailed information, please refer to pytube.io.

Installation

Pytube requires an installation of Python 3.6 or greater, as well as pip. (Pip is typically bundled with Python installations.)

To install from PyPI with pip:

$ python -m pip install pytube

Sometimes, the PyPI release becomes slightly outdated. To install from the source with pip:

$ python -m pip install git+https://github.com/pytube/pytube

Using pytube in a Python script

To download a video using the library in a script, you'll need to import the YouTube class from the library and pass an argument of the video URL. From there, you can access the streams and download them.

 >>> from pytube import YouTube

 >>> YouTube('https://youtu.be/2lAe1cqCOXo').streams.first().download()

 >>> yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')

 >>> yt.streams

  ... .filter(progressive=True, file_extension='mp4')

  ... .order_by('resolution')

  ... .desc()

  ... .first()

  ... .download()

Using the command-line interface

Using the CLI is remarkably straightforward as well. To download a video at the highest progressive quality, you can use the following command:

$ pytube https://youtube.com/watch?v=2lAe1cqCOXo

You can also do the same for a playlist:

$ pytube https://www.youtube.com/playlist?list=PLS1QulWo1RIaJECMeUT4LFwJ-ghgoSH6n

Metadata

Release files for pytubefixaugust24 15.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytubefixaugust24 15.0.0
File Size Uploaded Provenance Actions
pytubefixaugust24-15.0.0.tar.gz 69.6 kB Without provenance Details for pytubefixaugust24-15.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytubefixaugust24 15.0.0
File Interpreter ABI Platform Actions
pytubefixaugust24-15.0.0-py3-none-any.whl Python 3 none any Details for pytubefixaugust24-15.0.0-py3-none-any.whl

Total release size: 128.1 kB

Release files / pytubefixaugust24-15.0.0.tar.gz

Download URL pytubefixaugust24-15.0.0.tar.gz
Size 69.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a075524df52392fbc9f34485bd2c730136f6678b3c4c785f7623c423a7a15ecc
BLAKE2b-256 checksum
How to use checksums
de4e19e00fb6ee7cf871e81c26341089463b8243c0784c460ecf1434b90a1c13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / pytubefixaugust24-15.0.0-py3-none-any.whl

Download URL pytubefixaugust24-15.0.0-py3-none-any.whl
Size 58.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
056417eed479e8b5f89565580dcfbfca8b7341302fb8ac9eb0175d7e6742d853
BLAKE2b-256 checksum
How to use checksums
36d8054e41791b4d14c37d3af90dcd4bf07f97e58504c2786d2693b429f57ce6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Security for pytubefixaugust24 15.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

15.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page