Jose Diaz-Gonzalez
commited on
Commit
·
3c3f846
1
Parent(s):
ef70fdd
Combine README.nd and README.rst
Browse files- README.md +0 -146
- README.rst +172 -9
README.md
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
# A lightweight, dependency-free Python library for downloading YouTube Videos.
|
2 |
-
|
3 |
-
Downloading videos from YouTube shouldn't require some bloatware application,
|
4 |
-
it's usually a niche condition you want to do so in the first place. So I
|
5 |
-
present to you, PyTube!
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
## Installation
|
10 |
-
If you are on Mac OS X or Linux, chances are that one of the following two commands will work for you:
|
11 |
-
|
12 |
-
```
|
13 |
-
$ easy_install pytube
|
14 |
-
```
|
15 |
-
|
16 |
-
or even better:
|
17 |
-
|
18 |
-
```
|
19 |
-
$ pip install pytube
|
20 |
-
```
|
21 |
-
|
22 |
-
or you can get the [source code from github](https://github.com/NFicano/pytube).
|
23 |
-
|
24 |
-
### Roadmap
|
25 |
-
|
26 |
-
The only features I see implementing in the near future are:
|
27 |
-
|
28 |
-
- refactor console printing into separate command-line utility.
|
29 |
-
- Add nosetests
|
30 |
-
- Add Sphinx documentation
|
31 |
-
|
32 |
-
## Usage Example
|
33 |
-
|
34 |
-
``` python
|
35 |
-
from pytube import YouTube
|
36 |
-
|
37 |
-
# not necessary, just for demo purposes
|
38 |
-
from pprint import pprint
|
39 |
-
|
40 |
-
yt = YouTube()
|
41 |
-
|
42 |
-
# Set the video URL.
|
43 |
-
yt.url = "http://www.youtube.com/watch?v=Ik-RsDGPI5Y"
|
44 |
-
|
45 |
-
# Once set, you can see all the codec and quality options YouTube has made
|
46 |
-
# available for the perticular video by printing videos.
|
47 |
-
|
48 |
-
pprint(yt.videos)
|
49 |
-
|
50 |
-
#[<Video: MPEG-4 Visual (.3gp) - 144p>,
|
51 |
-
# <Video: MPEG-4 Visual (.3gp) - 240p>,
|
52 |
-
# <Video: Sorenson H.263 (.flv) - 240p>,
|
53 |
-
# <Video: H.264 (.flv) - 360p>,
|
54 |
-
# <Video: H.264 (.flv) - 480p>,
|
55 |
-
# <Video: H.264 (.mp4) - 360p>,
|
56 |
-
# <Video: H.264 (.mp4) - 720p>,
|
57 |
-
# <Video: VP8 (.webm) - 360p>,
|
58 |
-
# <Video: VP8 (.webm) - 480p>]
|
59 |
-
|
60 |
-
# The filename is automatically generated based on the video title.
|
61 |
-
# You can override this by manually setting the filename.
|
62 |
-
|
63 |
-
# view the auto generated filename:
|
64 |
-
print yt.filename
|
65 |
-
|
66 |
-
#Pulp Fiction - Dancing Scene [HD]
|
67 |
-
|
68 |
-
# set the filename:
|
69 |
-
yt.filename = 'Dancing Scene from Pulp Fiction'
|
70 |
-
|
71 |
-
# You can also filter the criteria by filetype.
|
72 |
-
|
73 |
-
pprint(yt.filter('flv'))
|
74 |
-
|
75 |
-
#[<Video: Sorenson H.263 (.flv) - 240p>,
|
76 |
-
# <Video: H.264 (.flv) - 360p>,
|
77 |
-
# <Video: H.264 (.flv) - 480p>]
|
78 |
-
|
79 |
-
# notice that the list is ordered by lowest resolution to highest. If you
|
80 |
-
# wanted the highest resolution available for a specific file type, you
|
81 |
-
# can simply do:
|
82 |
-
print yt.filter('mp4')[-1]
|
83 |
-
#<Video: H.264 (.mp4) - 720p>
|
84 |
-
|
85 |
-
# you can also get all videos for a given resolution
|
86 |
-
pprint(yt.filter(res='480p'))
|
87 |
-
|
88 |
-
#[<Video: H.264 (.flv) - 480p>,
|
89 |
-
#<Video: VP8 (.webm) - 480p>]
|
90 |
-
|
91 |
-
# to select a video by a specific resolution and filetype you can use the get
|
92 |
-
# method.
|
93 |
-
|
94 |
-
video = yt.get('mp4', '720p')
|
95 |
-
|
96 |
-
# NOTE: get() can only be used if and only if one object matches your criteria.
|
97 |
-
# for example:
|
98 |
-
|
99 |
-
pprint(yt.videos)
|
100 |
-
|
101 |
-
#[<Video: MPEG-4 Visual (.3gp) - 144p>,
|
102 |
-
# <Video: MPEG-4 Visual (.3gp) - 240p>,
|
103 |
-
# <Video: Sorenson H.263 (.flv) - 240p>,
|
104 |
-
# <Video: H.264 (.flv) - 360p>,
|
105 |
-
# <Video: H.264 (.flv) - 480p>,
|
106 |
-
# <Video: H.264 (.mp4) - 360p>,
|
107 |
-
# <Video: H.264 (.mp4) - 720p>,
|
108 |
-
# <Video: VP8 (.webm) - 360p>,
|
109 |
-
# <Video: VP8 (.webm) - 480p>]
|
110 |
-
|
111 |
-
# Notice we have two H.264 (.mp4) available to us.. now if we try to call get()
|
112 |
-
# on mp4..
|
113 |
-
|
114 |
-
video = yt.get('mp4')
|
115 |
-
# MultipleObjectsReturned: get() returned more than one object -- it returned 2!
|
116 |
-
|
117 |
-
# In this case, we'll need to specify both the codec (mp4) and resolution
|
118 |
-
# (either 360p or 720p).
|
119 |
-
|
120 |
-
# Okay, let's download it!
|
121 |
-
video.download()
|
122 |
-
|
123 |
-
# Downloading: Pulp Fiction - Dancing Scene.mp4 Bytes: 37561829
|
124 |
-
# 37561829 [100.00%]
|
125 |
-
|
126 |
-
# Note: If you wanted to choose the output directory, simply pass it as an
|
127 |
-
# argument to the download method.
|
128 |
-
video.download('/tmp/')
|
129 |
-
```
|
130 |
-
|
131 |
-
## Background
|
132 |
-
|
133 |
-
After missing the deadline to register for PyCon 2012, I decided to write what
|
134 |
-
became PyTube and crawler to collect all the YouTube links for the talks
|
135 |
-
on [PyVideos.org](http://pyvideo.org/).
|
136 |
-
|
137 |
-
To avoid having to encode them to mp4 (so I could watch them on my iPhone)
|
138 |
-
I wrote it so you could specify an encoding format.
|
139 |
-
|
140 |
-
In recently weeks interest has picked up in the project, so I decided to
|
141 |
-
dedicate more time to further its development and actively maintain it.
|
142 |
-
|
143 |
-
## Philosophy
|
144 |
-
|
145 |
-
My only real goal for this is to never require any third party dependancies,
|
146 |
-
to keep it simple and make it reliable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
======
|
2 |
+
pytube
|
3 |
+
======
|
4 |
|
5 |
+
A lightweight, dependency-free Python library for downloading YouTube Videos.
|
|
|
6 |
|
7 |
+
Description
|
8 |
+
===========
|
|
|
9 |
|
10 |
+
Downloading videos from YouTube shouldn't require some bloatware application,
|
11 |
+
it's usually a niche condition you want to do so in the first place. So I
|
12 |
+
present to you, PyTube!
|
13 |
|
14 |
+
Installation
|
15 |
+
============
|
16 |
|
17 |
+
If you are on Mac OS X or Linux, chances are that one of the following two commands will work for you:
|
18 |
+
|
19 |
+
Installation
|
20 |
+
============
|
21 |
+
|
22 |
+
Using PIP via PyPI
|
23 |
+
|
24 |
+
.. code:: bash
|
25 |
+
|
26 |
+
pip install pytube==0.1.16
|
27 |
+
|
28 |
+
Using PIP via Github
|
29 |
+
|
30 |
+
.. code:: bash
|
31 |
+
|
32 |
+
pip install git+git://github.com/NFicano/pytube.git@0.1.16#egg=pytube
|
33 |
+
|
34 |
+
Adding to your ``requirements.txt`` file (run ``pip install -r requirements.txt`` afterwards)
|
35 |
+
|
36 |
+
.. code:: bash
|
37 |
+
|
38 |
+
git+ssh://git@github.com/NFicano/pytube.git@0.1.16#egg=pytube
|
39 |
+
|
40 |
+
Manually via GIT
|
41 |
+
|
42 |
+
.. code:: bash
|
43 |
+
|
44 |
+
git clone git://github.com/NFicano/pytube.git pytube
|
45 |
+
cd pytube
|
46 |
+
python setup.py install
|
47 |
+
|
48 |
+
Roadmap
|
49 |
+
=======
|
50 |
+
|
51 |
+
The only features I see implementing in the near future are:
|
52 |
+
|
53 |
+
- refactor console printing into separate command-line utility.
|
54 |
+
- Add nosetests
|
55 |
+
- Add Sphinx documentation
|
56 |
+
|
57 |
+
Usage Example
|
58 |
+
=============
|
59 |
+
|
60 |
+
... code:: python
|
61 |
+
|
62 |
+
from pytube import YouTube
|
63 |
+
|
64 |
+
# not necessary, just for demo purposes
|
65 |
+
from pprint import pprint
|
66 |
+
|
67 |
+
yt = YouTube()
|
68 |
+
|
69 |
+
# Set the video URL.
|
70 |
+
yt.url = "http://www.youtube.com/watch?v=Ik-RsDGPI5Y"
|
71 |
+
|
72 |
+
# Once set, you can see all the codec and quality options YouTube has made
|
73 |
+
# available for the perticular video by printing videos.
|
74 |
+
|
75 |
+
pprint(yt.videos)
|
76 |
+
|
77 |
+
#[<Video: MPEG-4 Visual (.3gp) - 144p>,
|
78 |
+
# <Video: MPEG-4 Visual (.3gp) - 240p>,
|
79 |
+
# <Video: Sorenson H.263 (.flv) - 240p>,
|
80 |
+
# <Video: H.264 (.flv) - 360p>,
|
81 |
+
# <Video: H.264 (.flv) - 480p>,
|
82 |
+
# <Video: H.264 (.mp4) - 360p>,
|
83 |
+
# <Video: H.264 (.mp4) - 720p>,
|
84 |
+
# <Video: VP8 (.webm) - 360p>,
|
85 |
+
# <Video: VP8 (.webm) - 480p>]
|
86 |
+
|
87 |
+
# The filename is automatically generated based on the video title.
|
88 |
+
# You can override this by manually setting the filename.
|
89 |
+
|
90 |
+
# view the auto generated filename:
|
91 |
+
print yt.filename
|
92 |
+
|
93 |
+
#Pulp Fiction - Dancing Scene [HD]
|
94 |
+
|
95 |
+
# set the filename:
|
96 |
+
yt.filename = 'Dancing Scene from Pulp Fiction'
|
97 |
+
|
98 |
+
# You can also filter the criteria by filetype.
|
99 |
+
|
100 |
+
pprint(yt.filter('flv'))
|
101 |
+
|
102 |
+
#[<Video: Sorenson H.263 (.flv) - 240p>,
|
103 |
+
# <Video: H.264 (.flv) - 360p>,
|
104 |
+
# <Video: H.264 (.flv) - 480p>]
|
105 |
+
|
106 |
+
# notice that the list is ordered by lowest resolution to highest. If you
|
107 |
+
# wanted the highest resolution available for a specific file type, you
|
108 |
+
# can simply do:
|
109 |
+
print yt.filter('mp4')[-1]
|
110 |
+
#<Video: H.264 (.mp4) - 720p>
|
111 |
+
|
112 |
+
# you can also get all videos for a given resolution
|
113 |
+
pprint(yt.filter(res='480p'))
|
114 |
+
|
115 |
+
#[<Video: H.264 (.flv) - 480p>,
|
116 |
+
#<Video: VP8 (.webm) - 480p>]
|
117 |
+
|
118 |
+
# to select a video by a specific resolution and filetype you can use the get
|
119 |
+
# method.
|
120 |
+
|
121 |
+
video = yt.get('mp4', '720p')
|
122 |
+
|
123 |
+
# NOTE: get() can only be used if and only if one object matches your criteria.
|
124 |
+
# for example:
|
125 |
+
|
126 |
+
pprint(yt.videos)
|
127 |
+
|
128 |
+
#[<Video: MPEG-4 Visual (.3gp) - 144p>,
|
129 |
+
# <Video: MPEG-4 Visual (.3gp) - 240p>,
|
130 |
+
# <Video: Sorenson H.263 (.flv) - 240p>,
|
131 |
+
# <Video: H.264 (.flv) - 360p>,
|
132 |
+
# <Video: H.264 (.flv) - 480p>,
|
133 |
+
# <Video: H.264 (.mp4) - 360p>,
|
134 |
+
# <Video: H.264 (.mp4) - 720p>,
|
135 |
+
# <Video: VP8 (.webm) - 360p>,
|
136 |
+
# <Video: VP8 (.webm) - 480p>]
|
137 |
+
|
138 |
+
# Notice we have two H.264 (.mp4) available to us.. now if we try to call get()
|
139 |
+
# on mp4..
|
140 |
+
|
141 |
+
video = yt.get('mp4')
|
142 |
+
# MultipleObjectsReturned: get() returned more than one object -- it returned 2!
|
143 |
+
|
144 |
+
# In this case, we'll need to specify both the codec (mp4) and resolution
|
145 |
+
# (either 360p or 720p).
|
146 |
+
|
147 |
+
# Okay, let's download it!
|
148 |
+
video.download()
|
149 |
+
|
150 |
+
# Downloading: Pulp Fiction - Dancing Scene.mp4 Bytes: 37561829
|
151 |
+
# 37561829 [100.00%]
|
152 |
+
|
153 |
+
# Note: If you wanted to choose the output directory, simply pass it as an
|
154 |
+
# argument to the download method.
|
155 |
+
video.download('/tmp/')
|
156 |
+
|
157 |
+
|
158 |
+
Background
|
159 |
+
==========
|
160 |
+
|
161 |
+
After missing the deadline to register for PyCon 2012, I decided to write what
|
162 |
+
became PyTube and crawler to collect all the YouTube links for the talks
|
163 |
+
on PyVideos.
|
164 |
+
|
165 |
+
To avoid having to encode them to mp4 (so I could watch them on my iPhone)
|
166 |
+
I wrote it so you could specify an encoding format.
|
167 |
+
|
168 |
+
In recently weeks interest has picked up in the project, so I decided to
|
169 |
+
dedicate more time to further its development and actively maintain it.
|
170 |
+
|
171 |
+
Philosophy
|
172 |
+
==========
|
173 |
+
|
174 |
+
My only real goal for this is to never require any third party dependancies,
|
175 |
+
to keep it simple and make it reliable.
|
176 |
+
|
177 |
+
.. _PyVideos: http://pyvideo.org/
|