File size: 3,746 Bytes
1302e44 5c83b18 d0ef488 5c83b18 1302e44 d0ef488 bff3e77 d0ef488 1302e44 685331f d0ef488 685331f 85080c8 5c83b18 d0ef488 685331f 1302e44 685331f d0ef488 bff3e77 abb922e 685331f d0ef488 685331f d0ef488 685331f d0ef488 685331f bff3e77 685331f d0ef488 685331f 9e1bc1b 685331f 9e1bc1b cee0d50 9e1bc1b 685331f d0ef488 685331f 1302e44 685331f d68bda8 1302e44 5c83b18 1302e44 685331f d0ef488 685331f 5340b13 685331f 5340b13 685331f 5340b13 685331f 5340b13 319fd41 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
<div align="center">
<p>
<a href="#"><img src="https://assets.nickficano.com/gh-pytube.min.svg" width="456" height="143" alt="pytube logo" /></a>
</p>
<p align="center">
<a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/dm/pytube?style=flat-square" alt="pypi"/></a>
<a href="https://pytube.io/en/latest/"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest&style=flat-square" /></a>
<a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/v/pytube?style=flat-square" /></a>
</p>
</div>
### 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](https://pytube.io). This is recommended
for most use cases. If you just want to quickly download a single video,
the [quickstart](#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](https://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:
```bash
$ python -m pip install pytube
```
Sometime, the pypi release becomes slightly outdated. To install from the
source with pip:
```bash
$ 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.
```python
>>> 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:
```bash
$ pytube https://youtube.com/watch?v=2lAe1cqCOXo
```
You can also do the same for a playlist:
```bash
$ pytube https://www.youtube.com/playlist?list=PLS1QulWo1RIaJECMeUT4LFwJ-ghgoSH6n
```
|