Skip to main content

Python 3 library for downloading YouTube Videos.

Project description

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytube-10.5.1.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

pytube-10.5.1-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file pytube-10.5.1.tar.gz.

File metadata

  • Download URL: pytube-10.5.1.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for pytube-10.5.1.tar.gz
Algorithm Hash digest
SHA256 bfa99ac358745abc80a66e0aad5f1f5503a875ad425551dbeee90e04a3aa93a2
MD5 6414855602094a6bd0cb26d75bd80560
BLAKE2b-256 3a872c5b61ceccd33b6bcdfad4177045de52c408f42a82413a24524ce8d6164e

See more details on using hashes here.

File details

Details for the file pytube-10.5.1-py3-none-any.whl.

File metadata

  • Download URL: pytube-10.5.1-py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

File hashes

Hashes for pytube-10.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88740fd8574554312d2897122a3fffcccacec84e0f84c639683c83425ad7717a
MD5 b720a801d66cf010a0e43c1198f5cac4
BLAKE2b-256 a4a7a82cf1e3f283953d18cd72862cde6b38ed3568aca347854ea912e5c6f082

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page