Skip to main content

pytube logo

pypi

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 pytube.io. 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 pytube.io.

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

Metadata

Release files for pytube 10.8.2

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.8.2
File Size Uploaded
pytube-10.8.2.tar.gz 57.8 kB Details

Built distribution (wheel)

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

Total release size: 103.9 kB

Release files / pytube-10.8.2.tar.gz

Download URL pytube-10.8.2.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5ba9e80e3324a5e50652ce819b49743adc7cf83606e645aedec9cdc61a4d0b30
BLAKE2b-256 checksum
How to use checksums
793bc7cba1af2bbf2a0fbd1ec3f775d5701b34e09dbf425049770b6ebcf8d8d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

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

Download URL pytube-10.8.2-py3-none-any.whl
Size 46.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a36bfa3b136b4a97e770cfbd6cc6222e8a24d1a9db050d84703f23a126492f79
BLAKE2b-256 checksum
How to use checksums
28bd30f8e4bfd3a497e820bf6fc59b6f76152e9538b8806621fdf3ec3f79150f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

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

This release

10.8.2 This release

2 release files

10.7.2

2 release files

10.6.1

2 release files

10.6.0

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