Skip to main content

Python 3 library for downloading YouTube Videos.

Project description

pytube logo

pypi

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:

pip uninstall pytube -y
pip install pytube2

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.download_helper import (
    download_videos_from_channels,
    download_video,
    download_videos_from_list,
)

# download_videos_from_channels(channels=["channel1", "channel2"])
# download_videos_from_list(filename="videos.txt")
# download_video(url="https://www.youtube.com/watch?v=VIDEO_ID")

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

Project details


Download files

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

Source Distribution

pytube2-15.0.11.tar.gz (70.8 kB view details)

Uploaded Source

Built Distribution

pytube2-15.0.11-py3-none-any.whl (60.3 kB view details)

Uploaded Python 3

File details

Details for the file pytube2-15.0.11.tar.gz.

File metadata

  • Download URL: pytube2-15.0.11.tar.gz
  • Upload date:
  • Size: 70.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for pytube2-15.0.11.tar.gz
Algorithm Hash digest
SHA256 a8a2ef64d3e5255c86aec25ba1fbf807ebe4411e1d88d75034eded21d2ac721b
MD5 b649928625b2b55d185d9f2d70af983f
BLAKE2b-256 ff7366319881c71d16f510eb6632c0a3b7d102c437f3877ba29b9a4ef79ca5e7

See more details on using hashes here.

File details

Details for the file pytube2-15.0.11-py3-none-any.whl.

File metadata

  • Download URL: pytube2-15.0.11-py3-none-any.whl
  • Upload date:
  • Size: 60.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for pytube2-15.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6ff59ed786d37d97d736b5590ca37d8fa1b12097434e0e18a0ac2b40ece9be9b
MD5 d34dd442fcbeabbf685c7787d8f85fd4
BLAKE2b-256 aadd3a0ffef783d09b86bbff91e8de6b692060ddb64f52343db459e09e337ee1

See more details on using hashes here.

Supported by

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