Nick Ficano commited on
Commit
8740488
·
1 Parent(s): aee8e93

Updated readme.

Browse files

* Removed background section
* Added example cli usage.

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