Python 3 library for downloading YouTube Videos.
Project description
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
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
Built Distribution
File details
Details for the file pytube-15.0.0.tar.gz
.
File metadata
- Download URL: pytube-15.0.0.tar.gz
- Upload date:
- Size: 67.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 076052efe76f390dfa24b1194ff821d4e86c17d41cb5562f3a276a8bcbfc9d1d |
|
MD5 | fd11326cb975238b63e1365722ecd814 |
|
BLAKE2b-256 | d8e716fec46c8d255c4bbc4b185d89c91dc92cdb802836570d8004d0db169c91 |
File details
Details for the file pytube-15.0.0-py3-none-any.whl
.
File metadata
- Download URL: pytube-15.0.0-py3-none-any.whl
- Upload date:
- Size: 57.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b9904749e213485780d7eb606e5e5b8e4341aa4dccf699160876da00e12d78 |
|
MD5 | 6c601c9803949146e294464d11bf1156 |
|
BLAKE2b-256 | 5164bcf8632ed2b7a36bbf84a0544885ffa1d0b4bcf25cc0903dba66ec5fdad9 |