Skip to main content

Actively soliciting contributers!

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

pytube

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

Documentation

Detailed documentation about how to use the library can be found on our readthedocs page. This is recommended for most use cases. If you just want to quickly download a single video, the quickstart 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.

Finally pytube also includes a command-line utility, allowing you to quickly download videos right from terminal.

Features

  • Support for both progressive & DASH streams
  • Support for downloading 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 is only meant to cover the most basic usage of the library. For more detailed information, please refer to our readthedocs page.

Installation

Pytube requires an installation of python 3.6 or greater, as well as pip. Pip is typically bundled with python installations, and you can find options for how to install python at https://python.org.

To install from pypi with pip:

$ python -m pip install pytube

Sometime, 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 first import the YouTube class from the library, and pass it 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 extremely 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

Release files for pytube 10.5.3

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

Source distribution (sdist)

Source distribution for pytube 10.5.3
File Size Uploaded
pytube-10.5.3.tar.gz 54.0 kB Details

Built distribution (wheel)

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

Total release size: 96.8 kB

Release files / pytube-10.5.3.tar.gz

Download URL pytube-10.5.3.tar.gz
Size 54.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6d02bfef04d3aeeb443d1fb13128bb784735c836a797038bc8171b0a38dfb218
BLAKE2b-256 checksum
How to use checksums
a5ae669c9437bf3de91a49ae9545ce0c94ea421dfa0fb1f70831f6cf663a3585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release files / pytube-10.5.3-py3-none-any.whl

Download URL pytube-10.5.3-py3-none-any.whl
Size 42.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e81cdaadb8469a884e022d1b6e11fa6ddecb8be67b48f5a2a6e67f544d670a06
BLAKE2b-256 checksum
How to use checksums
98feab5c42a4be08d302d11e228bd5c4a63c1cb2fce9041881f8f9ef9a1fe34e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release history Release notifications | RSS feed

12.1.3

2 release files

12.1.2

2 release files

12.1.1

2 release files

12.0.0

2 release files

11.0.2

2 release files

11.0.1

2 release files

10.9.3

2 release files

10.8.5

2 release files

10.8.3

2 release files

10.8.2

2 release files

10.7.2

2 release files

10.6.1

2 release files

10.6.0

2 release files

This release

10.5.3 This release

2 release files

10.5.1

2 release files

10.4.1

2 release files

10.0.0

2 release files

9.7.3

2 release files

9.7.2

2 release files

9.7.0

2 release files

9.6.0

2 release files

9.5.3

2 release files

9.5.2

2 release files

9.5.1

2 release files

9.5.0

2 release files

9.4.0

2 release files

9.3.5

2 release files

9.3.3

2 release files

9.3.2

2 release files

9.3.0

2 release files

9.2.3

2 release files

9.2.2

2 release files

9.2.0

2 release files

9.1.0

2 release files

9.0.6

2 release files

9.0.4

2 release files

9.0.2

2 release files

9.0.0

2 release files

8.0.2

2 release files

8.0.0

2 release files

7.0.18

2 release files

7.0.16

2 release files

7.0.14

2 release files

7.0.12

2 release files

7.0.10

2 release files

7.0.9

2 release files

7.0.8

2 release files

7.0.6

2 release files

7.0.4

2 release files

7.0.2

2 release files

7.0.0

2 release files

6.4.2

2 release files

6.4.0

2 release files

6.3.0

2 release files

6.2.2

2 release files

6.2.1

1 release file

6.1.11

1 release file

6.1.10

1 release file

6.1.8

1 release file

6.1.5

1 release file

6.1.4

1 release file

6.1.3

1 release file

6.1.2

1 release file

6.1.0

1 release file

6.0.2

1 release file

6.0.1

1 release file

6.0.0

1 release file

5.1.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.3.3

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

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