nficano commited on
Commit
1302e44
·
1 Parent(s): 6daa0e6

added logo

Browse files
Files changed (1) hide show
  1. README.rst → README.md +139 -159
README.rst → README.md RENAMED
@@ -1,27 +1,17 @@
1
- ======
2
- pytube
3
- ======
4
-
5
- .. image:: https://img.shields.io/pypi/v/pytube.svg
6
- :alt: Pypi
7
- :target: https://pypi.python.org/pypi/pytube/
8
-
9
- .. image:: https://travis-ci.org/nficano/pytube.svg?branch=master
10
- :alt: Build status
11
- :target: https://travis-ci.org/nficano/pytube
12
 
13
- .. image:: https://readthedocs.org/projects/python-pytube/badge/?version=latest
14
- :alt: Documentation Status
15
- :target: http://python-pytube.readthedocs.io/en/latest/?badge=latest
16
-
17
- .. image:: https://coveralls.io/repos/github/nficano/pytube/badge.svg?branch=master#23e6f7ac56dd3bde
18
- :alt: Code Coverage
19
- :target: https://coveralls.io/github/nficano/pytube?branch=master
20
-
21
- .. image:: https://img.shields.io/pypi/pyversions/pytube.svg
22
- :alt: Python Versions
23
- :target: https://pypi.python.org/pypi/pytube/
24
 
 
 
25
  *pytube* is a lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
26
 
27
  Description
@@ -35,16 +25,18 @@ YouTube is the most popular video-sharing platform in the world and as a hacker
35
 
36
  Finally *pytube* also includes a command-line utility, allowing you to quickly download videos right from terminal.
37
 
38
- **Behold, a perfect balance of simplicity versus flexibility**::
39
 
40
- >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
41
- >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
42
- >>> yt.streams
43
- ... .filter(progressive=True, file_extension='mp4')
44
- ... .order_by('resolution')
45
- ... .desc()
46
- ... .first()
47
- ... .download()
 
 
48
 
49
  Features
50
  --------
@@ -64,51 +56,49 @@ Installation
64
 
65
  Download using pip via pypi.
66
 
67
- .. code-block:: bash
68
-
69
- pip install pytube
70
 
71
  Getting started
72
  ---------------
73
 
74
  Let's begin with showing how easy it is to download a video with pytube:
75
 
76
- .. code-block:: python
77
-
78
- >>> from pytube import YouTube
79
- >>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download()
80
-
81
  This example will download the highest quality progressive download stream available.
82
 
83
  Next, let's explore how we would view what video streams are available:
84
 
85
- .. code-block:: python
86
-
87
- >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
88
- >>> yt.streams.all()
89
- [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
90
- <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
91
- <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
92
- <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
93
- <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
94
- <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
95
- <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
96
- <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
97
- <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
98
- <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
99
- <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
100
- <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
101
- <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
102
- <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
103
- <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
104
- <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
105
- <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
106
- <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
107
- <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
108
- <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
109
- <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
110
- <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
111
-
112
  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).
113
 
114
  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.
@@ -117,124 +107,116 @@ The legacy streams that contain the audio and video in a single file (referred t
117
 
118
  To only view these progressive download streams:
119
 
120
- .. code-block:: python
121
-
122
- >>> yt.streams.filter(progressive=True).all()
123
- [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
124
- <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
125
- <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
126
- <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
127
- <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">]
128
 
129
  Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do:
130
 
131
- .. code-block:: python
132
-
133
- >>> yt.streams.filter(adaptive=True).all()
134
- [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
135
- <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
136
- <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
137
- <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
138
- <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
139
- <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
140
- <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
141
- <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
142
- <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
143
- <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
144
- <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
145
- <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
146
- <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
147
- <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
148
- <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
149
- <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
150
- <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
151
-
152
 
153
  You can also download a complete Youtube playlist:
154
 
155
- .. code-block:: python
156
-
157
- >>> from pytube import Playlist
158
- >>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU")
159
- >>> pl.download_all()
160
-
161
  This will download the highest progressive stream available (generally 720p) from the given playlist. Later more option would be give users flexibility
162
  to choose video resolution. Playlist videos will be downloaded in the directory from where the command was run.
163
 
164
-
165
  Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones.
166
 
167
  To list the audio only streams:
168
 
169
- .. code-block:: python
170
-
171
- >>> yt.streams.filter(only_audio=True).all()
172
- [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
173
- <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
174
- <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
175
- <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
176
- <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
177
-
178
 
179
  To list only ``mp4`` streams:
180
 
181
- .. code-block:: python
182
-
183
- >>> yt.streams.filter(subtype='mp4').all()
184
- [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
185
- <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
186
- <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
187
- <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
188
- <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
189
- <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
190
- <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
191
- <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
192
- <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">]
193
-
194
 
195
  Multiple filters can also be specified:
196
 
197
- .. code-block:: python
198
-
199
- >>> yt.streams.filter(subtype='mp4', progressive=True).all()
200
- >>> # this can also be expressed as:
201
- >>> yt.streams.filter(subtype='mp4').filter(progressive=True).all()
202
- [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
203
- <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">]
204
-
205
  You also have an interface to select streams by their itag, without needing to filter:
206
 
207
- .. code-block:: python
208
-
209
- >>> yt.streams.get_by_itag(22)
210
- <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">
211
-
212
 
213
  If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate":
214
 
215
- .. code-block:: python
216
-
217
- >>> yt.streams.filter(progressive=True).order_by('resolution').desc().all()
218
-
219
  Note that ``order_by`` cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it.
220
 
221
  If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function:
222
 
223
- .. code-block:: python
224
-
225
- >>> def convert_to_aac(stream, file_handle):
226
- # do work
227
- >>> yt.register_on_complete_callback(convert_to_aac)
228
 
 
 
229
 
230
  Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well:
231
 
232
- .. code-block:: python
233
-
234
- >>> def show_progress_bar(stream, chunk, file_handle, bytes_remaining):
235
- # do work
236
- >>> yt.register_on_progress_callback(show_progress_bar)
237
 
 
 
238
 
239
 
240
  Command-line interface
@@ -244,15 +226,13 @@ pytube also ships with a tiny cli interface for downloading and probing videos.
244
 
245
  Let's start with downloading:
246
 
247
- .. code-block:: bash
248
-
249
- pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22
250
-
251
  To view available streams:
252
 
253
- .. code-block:: bash
254
-
255
- pytube http://youtube.com/watch?v=9bZkp7q19f0 --list
256
-
257
 
258
  Finally, if you're filing a bug report, the cli contains a switch called ``--build-playback-report``, which bundles up the state, allowing others to easily replay your issue.
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ <div align="center">
3
+ <img src="./images/pytube.png" width="400" height="375" alt="pytube logo" /><br>
4
+ <p align="center">
5
+ <img src="https://img.shields.io/pypi/v/pytube.svg" alt="pypi">
6
+ <a href="https://travis-ci.org/nficano/pytube"><img src="https://travis-ci.org/nficano/pytube.svg?branch=master" /></a>
7
+ <a href="http://python-pytube.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest" /></a>
8
+ <a href="https://coveralls.io/github/nficano/pytube?branch=master"><img src="https://coveralls.io/repos/github/nficano/pytube/badge.svg?branch=master#23e6f7ac56dd3bde" /></a>
9
+ <a href="https://pypi.python.org/pypi/pytube/"><img src="https://img.shields.io/pypi/pyversions/pytube.svg" /></a>
10
+ </p>
11
+ </div>
 
12
 
13
+ pytube
14
+ ======
15
  *pytube* is a lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
16
 
17
  Description
 
25
 
26
  Finally *pytube* also includes a command-line utility, allowing you to quickly download videos right from terminal.
27
 
28
+ **Behold, a perfect balance of simplicity versus flexibility**:
29
 
30
+ ```python
31
+ >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
32
+ >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
33
+ >>> yt.streams
34
+ ... .filter(progressive=True, file_extension='mp4')
35
+ ... .order_by('resolution')
36
+ ... .desc()
37
+ ... .first()
38
+ ... .download()
39
+ ```
40
 
41
  Features
42
  --------
 
56
 
57
  Download using pip via pypi.
58
 
59
+ ```bash
60
+ pip install pytube
61
+ ```
62
 
63
  Getting started
64
  ---------------
65
 
66
  Let's begin with showing how easy it is to download a video with pytube:
67
 
68
+ ```python
69
+ >>> from pytube import YouTube
70
+ >>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download()
71
+ ```
 
72
  This example will download the highest quality progressive download stream available.
73
 
74
  Next, let's explore how we would view what video streams are available:
75
 
76
+ ```python
77
+ >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
78
+ >>> yt.streams.all()
79
+ [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
80
+ <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
81
+ <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
82
+ <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
83
+ <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
84
+ <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
85
+ <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
86
+ <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
87
+ <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
88
+ <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
89
+ <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
90
+ <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
91
+ <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
92
+ <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
93
+ <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
94
+ <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
95
+ <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
96
+ <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
97
+ <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
98
+ <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
99
+ <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
100
+ <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
101
+ ```
 
102
  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).
103
 
104
  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.
 
107
 
108
  To only view these progressive download streams:
109
 
110
+ ```python
111
+ >>> yt.streams.filter(progressive=True).all()
112
+ [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
113
+ <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
114
+ <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
115
+ <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
116
+ <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">]
117
+ ```
118
 
119
  Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do:
120
 
121
+ ```python
122
+ >>> yt.streams.filter(adaptive=True).all()
123
+ [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
124
+ <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
125
+ <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
126
+ <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
127
+ <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
128
+ <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
129
+ <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
130
+ <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
131
+ <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
132
+ <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
133
+ <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
134
+ <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
135
+ <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
136
+ <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
137
+ <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
138
+ <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
139
+ <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
140
+ ```
 
141
 
142
  You can also download a complete Youtube playlist:
143
 
144
+ ```python
145
+ >>> from pytube import Playlist
146
+ >>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU")
147
+ >>> pl.download_all()
148
+ ```
 
149
  This will download the highest progressive stream available (generally 720p) from the given playlist. Later more option would be give users flexibility
150
  to choose video resolution. Playlist videos will be downloaded in the directory from where the command was run.
151
 
 
152
  Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones.
153
 
154
  To list the audio only streams:
155
 
156
+ ```python
157
+ >>> yt.streams.filter(only_audio=True).all()
158
+ [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
159
+ <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
160
+ <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
161
+ <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
162
+ <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
163
+ ```
 
164
 
165
  To list only ``mp4`` streams:
166
 
167
+ ```python
168
+ >>> yt.streams.filter(subtype='mp4').all()
169
+ [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
170
+ <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
171
+ <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
172
+ <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
173
+ <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
174
+ <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
175
+ <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
176
+ <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
177
+ <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">]
178
+ ```
 
179
 
180
  Multiple filters can also be specified:
181
 
182
+ ```python
183
+ >>> yt.streams.filter(subtype='mp4', progressive=True).all()
184
+ >>> # this can also be expressed as:
185
+ >>> yt.streams.filter(subtype='mp4').filter(progressive=True).all()
186
+ [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
187
+ <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">]
188
+ ```
 
189
  You also have an interface to select streams by their itag, without needing to filter:
190
 
191
+ ```python
192
+ >>> yt.streams.get_by_itag(22)
193
+ <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">
194
+ ```
 
195
 
196
  If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate":
197
 
198
+ ```python
199
+ >>> yt.streams.filter(progressive=True).order_by('resolution').desc().all()
200
+ ```
 
201
  Note that ``order_by`` cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it.
202
 
203
  If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function:
204
 
205
+ ```python
206
+ >>> def convert_to_aac(stream, file_handle):
207
+ return # do work
 
 
208
 
209
+ >>> yt.register_on_complete_callback(convert_to_aac)
210
+ ```
211
 
212
  Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well:
213
 
214
+ ```python
215
+ >>> def show_progress_bar(stream, chunk, file_handle, bytes_remaining):
216
+ return # do work
 
 
217
 
218
+ >>> yt.register_on_progress_callback(show_progress_bar)
219
+ ```
220
 
221
 
222
  Command-line interface
 
226
 
227
  Let's start with downloading:
228
 
229
+ ```bash
230
+ $ pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22
231
+ ```
 
232
  To view available streams:
233
 
234
+ ```bash
235
+ $ pytube http://youtube.com/watch?v=9bZkp7q19f0 --list
236
+ ```
 
237
 
238
  Finally, if you're filing a bug report, the cli contains a switch called ``--build-playback-report``, which bundles up the state, allowing others to easily replay your issue.