updated readme
Browse files- README.rst +59 -122
- pytube/cli.py +1 -1
README.rst
CHANGED
@@ -48,141 +48,78 @@ Library usage
|
|
48 |
|
49 |
.. code:: python
|
50 |
|
51 |
-
from pytube import YouTube
|
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 |
-
# NOTE: get() can only be used if and only if one object matches your criteria.
|
109 |
-
# for example:
|
110 |
-
|
111 |
-
print(yt.videos)
|
112 |
-
|
113 |
-
#[<Video: MPEG-4 Visual (.3gp) - 144p>,
|
114 |
-
# <Video: MPEG-4 Visual (.3gp) - 240p>,
|
115 |
-
# <Video: Sorenson H.263 (.flv) - 240p>,
|
116 |
-
# <Video: H.264 (.flv) - 360p>,
|
117 |
-
# <Video: H.264 (.flv) - 480p>,
|
118 |
-
# <Video: H.264 (.mp4) - 360p>,
|
119 |
-
# <Video: H.264 (.mp4) - 720p>,
|
120 |
-
# <Video: VP8 (.webm) - 360p>,
|
121 |
-
# <Video: VP8 (.webm) - 480p>]
|
122 |
-
|
123 |
-
# Since we have two H.264 (.mp4) available to us... now if we try to call get()
|
124 |
-
# on mp4...
|
125 |
-
|
126 |
-
video = yt.get('mp4')
|
127 |
-
# MultipleObjectsReturned: 2 videos met criteria.
|
128 |
-
|
129 |
-
# In this case, we'll need to specify both the codec (mp4) and resolution
|
130 |
-
# (either 360p or 720p).
|
131 |
-
|
132 |
-
# Okay, let's download it! (a destination directory is required)
|
133 |
-
video.download('/tmp/')
|
134 |
|
135 |
Command-line usage
|
136 |
==================
|
137 |
|
138 |
-
You can download a video by simply passing the
|
139 |
-
setting it to the desired filetype:
|
140 |
|
141 |
.. code:: bash
|
142 |
|
143 |
-
$ pytube
|
144 |
-
|
145 |
-
|
146 |
-
Same thing for specifying a resolution:
|
147 |
-
|
148 |
-
.. code:: bash
|
149 |
|
150 |
-
$ pytube -r 720p http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
151 |
|
152 |
-
|
153 |
|
154 |
.. code:: bash
|
155 |
|
156 |
$ pytube http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
157 |
-
Resolution Extension
|
158 |
-
----------------------------
|
159 |
-
0 3gp 144p
|
160 |
-
1 3gp 240p
|
161 |
-
2 mp4 360p
|
162 |
-
3 mp4 720p
|
163 |
-
4 webm 360p
|
164 |
-
Enter choice:
|
165 |
-
|
166 |
-
|
167 |
-
You can see a list of available formats by passing the ``-s`` (or ``--show-available``) flag
|
168 |
-
|
169 |
-
.. code:: bash
|
170 |
-
|
171 |
-
$ pytube -s http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
You can also specify a download file path (``-p`` or ``--path=``):
|
176 |
-
|
177 |
-
.. code:: bash
|
178 |
-
|
179 |
-
$ pytube -e mp4 -p ~/Downloads/ http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
180 |
-
|
181 |
-
and/or optionally choose the filename (``-f`` or ``--filename=``):
|
182 |
-
|
183 |
-
.. code:: bash
|
184 |
-
|
185 |
-
$ pytube -e mp4 -f "Dancing Scene from Pulp Fiction" http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
186 |
|
187 |
Development
|
188 |
===========
|
|
|
48 |
|
49 |
.. code:: python
|
50 |
|
51 |
+
>>> from pytube import YouTube
|
52 |
+
|
53 |
+
>>> yt = YouTube("http://www.youtube.com/watch?v=9bZkp7q19f0")
|
54 |
+
|
55 |
+
>>> # Once set, you can see all the codec and quality options YouTube has made
|
56 |
+
>>> # available for the particular video by printing videos.
|
57 |
+
|
58 |
+
>>> yt.streams.all()
|
59 |
+
[<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">,
|
60 |
+
<Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">,
|
61 |
+
<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">,
|
62 |
+
<Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">,
|
63 |
+
<Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">]
|
64 |
+
|
65 |
+
>>> # for dash streams
|
66 |
+
[<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">,
|
67 |
+
<Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">,
|
68 |
+
<Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
|
69 |
+
<Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">,
|
70 |
+
<Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">,
|
71 |
+
<Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">,
|
72 |
+
<Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">,
|
73 |
+
<Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">,
|
74 |
+
<Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">,
|
75 |
+
<Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">,
|
76 |
+
<Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">,
|
77 |
+
<Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">,
|
78 |
+
<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">,
|
79 |
+
<Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">,
|
80 |
+
<Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
|
81 |
+
<Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
|
82 |
+
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
|
83 |
+
|
84 |
+
>>> # You can also filter the criteria by filetype.
|
85 |
+
>>> yt.dash_streams.filter(audio_codec='opus').all()
|
86 |
+
[<Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">,
|
87 |
+
<Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">,
|
88 |
+
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">]
|
89 |
+
|
90 |
+
>>> # Notice that the list is ordered by lowest resolution to highest. If you
|
91 |
+
>>> # wanted the highest resolution available for a specific file type, you
|
92 |
+
>>> # can do:
|
93 |
+
>>> yt.dash_streams.first()
|
94 |
+
<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">
|
95 |
+
|
96 |
+
>>> # You can also get all videos for a given resolution
|
97 |
+
>>> yt.dash_streams.filter(resolution='720p').all()
|
98 |
+
[<Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">,
|
99 |
+
<Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">]
|
100 |
+
|
101 |
+
>>> # To select a video by a specific itag you can use the get method.
|
102 |
+
>>> yt.dash_streams.get(251)
|
103 |
+
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">
|
104 |
+
|
105 |
+
# Okay, let's download it!
|
106 |
+
>>> yt.dash_streams.get(251).download()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
Command-line usage
|
109 |
==================
|
110 |
|
111 |
+
You can download a video by simply passing the ``--itag`` switch:
|
|
|
112 |
|
113 |
.. code:: bash
|
114 |
|
115 |
+
$ pytube http://www.youtube.com/watch?v=Ik-RsDGPI5Y --itag=22
|
|
|
|
|
|
|
|
|
|
|
116 |
|
|
|
117 |
|
118 |
+
To list all available formats use the ``--list`` switch:
|
119 |
|
120 |
.. code:: bash
|
121 |
|
122 |
$ pytube http://www.youtube.com/watch?v=Ik-RsDGPI5Y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
Development
|
125 |
===========
|
pytube/cli.py
CHANGED
@@ -12,7 +12,7 @@ import argparse
|
|
12 |
import os
|
13 |
import sys
|
14 |
|
15 |
-
from
|
16 |
|
17 |
|
18 |
def main():
|
|
|
12 |
import os
|
13 |
import sys
|
14 |
|
15 |
+
from pytube import YouTube
|
16 |
|
17 |
|
18 |
def main():
|