<div align="center">
<p align="center">
<a href="https://pypi.org/project/pytube3/"><img src="https://img.shields.io/pypi/v/pytube3.svg" alt="pypi"></a>
<a href="https://pypi.python.org/pypi/pytube3/"><img src="https://img.shields.io/pypi/pyversions/pytube3.svg" /></a>
<a href="https://travis-ci.com/hbmartin/pytube3/"><img src="https://travis-ci.org/hbmartin/pytube3.svg?branch=master" /></a>
<a href='https://pytube3.readthedocs.io/en/latest/?badge=latest'><img src='https://readthedocs.org/projects/pytube3/badge/?version=latest' alt='Documentation Status' /></a>
<a href="https://codecov.io/gh/hbmartin/pytube3"><img src="https://codecov.io/gh/hbmartin/pytube3/branch/master/graph/badge.svg" /></a>
<a href="https://www.codefactor.io/repository/github/hbmartin/pytube3/overview/master"><img src="https://www.codefactor.io/repository/github/hbmartin/pytube3/badge/master" alt="CodeFactor" /></a>
<a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" /></a>
<a href="https://twitter.com/hmartin"><img src="https://img.shields.io/badge/twitter-@hmartin-blue.svg?style=flat" /></a>
</p>
</div>
# pytube3
## Table of Contents
* [Installation](#installation)
* [Quick start](#quick-start)
* [Features](#features)
* [Usage](#usage)
* [Command-line interface](#command-line-interface)
* [Development](#development)
* [GUIs and other libraries](#guis-and-other-libraries)
## Installation
Download using pip via pypi.
```bash
$ pip install pytube3 --upgrade
```
(Mac/homebrew users may need to use ``pip3``)
## Quick start
```python
>>> from pytube import YouTube
>>> YouTube('https://youtu.be/9bZkp7q19f0').streams.get_highest_resolution().download()
>>>
>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
>>> yt.streams
... .filter(progressive=True, file_extension='mp4')
... .order_by('resolution')[-1]
... .download()
```
A GUI frontend for pytube3 is available at [YouTubeDownload](https://github.com/YouTubeDownload/YouTubeDownload)
## 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
## Usage
Let's begin with showing how easy it is to download a video with pytube:
```python
>>> from pytube import YouTube
>>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams[0].download()
```
This example will download the highest quality progressive download stream available.
Next, let's explore how we would view what video streams are available:
```python
>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
>>> print(yt.streams)
[<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
<Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
<Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
<Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
<Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
<Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
<Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
<Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
<Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
<Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
<Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
<Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
<Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
<Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
<Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
<Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
<Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
<Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
```
### Selecting an itag
You may notice that some streams listed have both a video codec and audio codec, while others have just video or just audio, this is a result of YouTube supporting a streaming technique called Dynamic Adaptive Streaming over HTTP (DASH).
In the context of pytube, the implications are for the highest quality streams; you now need to download both the audio and video tracks and then post-process them with software like FFmpeg to merge them.
The legacy streams that contain the audio and video in a single file (referred to as "progressive download") are still available, but only for resolutions 720p and below.
To only view these progressive download streams:
```python
>>> yt.streams.filter(progressive=True)
[<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
<Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
<Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
<Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">]
```
Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do:
```python
>>> yt.streams.filter(adaptive=True)
[<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
<Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
<Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
<Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
<Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
<Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
<Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
<Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
<Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
<Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
<Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
<Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
<Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
<Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
<Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
```
### Playlists
You can also download a complete Youtube playlist:
```python
>>> from pytube import Playlist
>>> playlist = Playlist("https://www.youtube.com/playlist?list=PLynhp4cZEpTbRs_PYISQ8v_uwO0_mDg_X")
>>> for video in playlist:
>>> video.streams.get_highest_resolution().downlo
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共44个文件
py:32个
txt:5个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:pytube3-9.6.3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
pytube3-9.6.3.tar.gz (44个子文件)
pytube3-9.6.3
MANIFEST.in 55B
PKG-INFO 18KB
pytube
itags.py 4KB
cli.py 15KB
captions.py 5KB
request.py 2KB
__main__.py 11KB
monostate.py 1KB
streams.py 11KB
helpers.py 5KB
__init__.py 538B
query.py 12KB
cipher.py 9KB
extract.py 10KB
contrib
playlist.py 9KB
__init__.py 0B
version.py 98B
exceptions.py 2KB
tests
test_streams.py 10KB
test_request.py 1KB
generate_fixture.py 617B
test_itags.py 300B
conftest.py 2KB
__init__.py 81B
test_helpers.py 2KB
test_extract.py 3KB
test_exceptions.py 775B
test_query.py 5KB
contrib
test_playlist.py 8KB
test_cli.py 16KB
test_main.py 992B
test_captions.py 5KB
test_cipher.py 651B
pytube3.egg-info
PKG-INFO 18KB
requires.txt 18B
SOURCES.txt 884B
entry_points.txt 45B
top_level.txt 7B
dependency_links.txt 1B
zip-safe 1B
LICENSE 1KB
setup.cfg 38B
setup.py 2KB
README.md 15KB
共 44 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 12w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功