README.md 10.2 KB
Newer Older
M
Mort Yao 已提交
1 2
# You-Get

M
Mort Yao 已提交
3
[You-Get](https://github.com/soimort/you-get) is a video downloader runs on Python 3. It aims at easing the download of videos on [YouTube](http://www.youtube.com), [Youku](http://www.youku.com)/[Tudou](http://www.tudou.com) (biggest online video providers in China), etc., in one script.
M
Mort Yao 已提交
4

M
Mort Yao 已提交
5
See the project homepage <http://www.soimort.org/you-get> for further documentation.
M
Mort Yao 已提交
6

M
Mort Yao 已提交
7 8 9 10
Fork me on GitHub: <https://github.com/soimort/you-get>

## Features

M
Mort Yao 已提交
11
### Supported Sites (As of Now)
M
Mort Yao 已提交
12 13

* YouTube <http://www.youtube.com>
M
Mort Yao 已提交
14 15 16 17 18 19 20
* Vimeo <http://vimeo.com>
* Youku (优酷) <http://www.youku.com>
* Tudou (土豆) <http://www.tudou.com>
* YinYueTai (音悦台) <http://www.yinyuetai.com>
* AcFun <http://www.acfun.tv>
* bilibili <http://www.bilibili.tv>
* CNTV (中国网络电视台) <http://www.cntv.cn>
M
Mort Yao 已提交
21
* ifeng (凤凰视频) <http://v.ifeng.com>
M
Mort Yao 已提交
22 23 24 25 26 27
* iQIYI (爱奇艺) <http://www.iqiyi.com>
* Ku6 (酷6网) <http://www.ku6.com>
* PPTV <http://www.pptv.com>
* Sina (新浪视频) <http://video.sina.com.cn>
* Sohu (搜狐视频) <http://tv.sohu.com>
* 56 (56网) <http://www.56.com>
M
Mort Yao 已提交
28

M
Mort Yao 已提交
29 30 31 32 33 34
## Dependencies

* [Python 3](http://www.python.org/download/releases/)
* __(Optional)__ [FFmpeg](http://ffmpeg.org)
    * Used for converting and joining video files.

M
Mort Yao 已提交
35 36 37 38
## Installation

### 1. Install via [Pip](http://www.pip-installer.org/):

M
Mort Yao 已提交
39
    $ pip install you-get
M
Mort Yao 已提交
40 41 42 43 44 45 46
    
   Check if the installation was successful:
    
    $ you-get -V

### 2. Install via [EasyInstall](http://pypi.python.org/pypi/setuptools):

M
Mort Yao 已提交
47
    $ easy_install you-get
M
Mort Yao 已提交
48 49 50 51 52
    
   Check if the installation was successful:
    
    $ you-get -V

M
Mort Yao 已提交
53 54 55
### 3. Install from Git:

    $ git clone git://github.com/soimort/you-get.git
M
Mort Yao 已提交
56 57 58
    
   Use the raw script without installation:
    
M
Mort Yao 已提交
59
    $ cd you-get/
M
Mort Yao 已提交
60 61 62 63 64 65
    $ ./you-get -V
    
   To install the package into the system path, execute:
    
    $ make install
    
M
Mort Yao 已提交
66
   Or (on Windows):
M
Mort Yao 已提交
67 68 69 70 71 72 73
    
    > setup.py install
    
   Check if the installation was successful:
    
    $ you-get -V

M
Mort Yao 已提交
74 75 76 77
### 4. Direct download (from <https://github.com/soimort/you-get/zipball/master>):
    
    $ wget -O you-get.zip https://github.com/soimort/you-get/zipball/master
    $ unzip you-get.zip
M
Mort Yao 已提交
78 79 80
    
   Use the raw script without installation:
    
M
Mort Yao 已提交
81
    $ cd soimort-you-get-*/
M
Mort Yao 已提交
82 83 84 85 86 87
    $ ./you-get -V
    
   To install the package into the system path, execute:
    
    $ make install
    
M
Mort Yao 已提交
88
   Or (on Windows):
M
Mort Yao 已提交
89 90 91 92 93 94 95
    
    > setup.py install
    
   Check if the installation was successful:
    
    $ you-get -V

M
Mort Yao 已提交
96 97 98
### 5. Install from [AUR (Arch User Repository)](http://aur.archlinux.org/):

   Click [here](https://aur.archlinux.org/packages.php\?ID=62576).
M
Mort Yao 已提交
99

M
Mort Yao 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113
## Examples (For End-Users)

Display the information of the video without downloading:

    $ you-get -i http://www.youtube.com/watch?v=sGwy8DsUJ4M

Download the video:

    $ you-get http://www.youtube.com/watch?v=sGwy8DsUJ4M

Download multiple videos:

    $ you-get http://www.youtube.com/watch?v=sGwy8DsUJ4M http://www.youtube.com/watch?v=8bQlxQJEzLk

M
Mort Yao 已提交
114
By default, program will skip any video that already exists in the local directory when downloading. If a temporary file (ends with a ".download" filename extension) is found, program will resume the download from last session.
M
Mort Yao 已提交
115

M
Mort Yao 已提交
116
To enforce re-downloading of videos, use '-f' option (this will overwrite any existing video or temporary file, rather than skipping or resuming them):
M
Mort Yao 已提交
117 118 119

    $ you-get -f http://www.youtube.com/watch?v=sGwy8DsUJ4M

M
Mort Yao 已提交
120
Set the output directory for downloaded files:
M
Mort Yao 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139

    $ you-get -o ~/Downloads http://www.youtube.com/watch?v=sGwy8DsUJ4M

Use a specific HTTP proxy for downloading:

    $ you-get -x 127.0.0.1:8087 http://www.youtube.com/watch?v=sGwy8DsUJ4M

By default, Python will apply the system proxy settings (i.e. environment variable $http_proxy). To cancel the use of proxy, use '--no-proxy' option:

    $ you-get --no-proxy http://www.youtube.com/watch?v=sGwy8DsUJ4M

## Command-Line Options

For a complete list of all available options, see:

    $ you-get --help

## Examples (For Developers)

M
Mort Yao 已提交
140
In Python 3 (interactive):
M
Mort Yao 已提交
141 142 143 144

    >>> import you_get
    
    >>> you_get.__version__
M
Mort Yao 已提交
145
    '0.2'
M
Mort Yao 已提交
146 147 148 149 150 151 152 153 154 155 156 157
    
    >>> you_get.youtube_download("http://www.youtube.com/watch?v=8bQlxQJEzLk", info_only = True)
    Video Site: YouTube.com
    Title:      If you're good at something, never do it for free!
    Type:       WebM video (video/webm)
    Size:       0.13 MB (133176 Bytes)
    
    >>> you_get.any_download("http://www.youtube.com/watch?v=sGwy8DsUJ4M") 
    Video Site: YouTube.com
    Title:      Mort from Madagascar LIKES
    Type:       WebM video (video/webm)
    Size:       1.78 MB (1867072 Bytes)
M
Mort Yao 已提交
158
    
M
Mort Yao 已提交
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    Downloading Mort from Madagascar LIKES.webm ...
    100.0% (  1.8/1.8  MB) [========================================] 1/1

## API Reference

See source code.

## License

You-Get is licensed under the [MIT license](https://raw.github.com/soimort/you-get/master/LICENSE.txt).



***



# You-Get - 中文说明

[You-Get](https://github.com/soimort/you-get)是一个基于Python 3的视频下载工具。之所以写它的主要原因是,我找不到一个现成的下载工具能够同时支持[YouTube](http://www.youtube.com/)[优酷](http://www.youku.com/);而且,几乎所有以前的视频下载程序都是基于Python 2的。

M
Mort Yao 已提交
180 181 182 183
项目主页:<http://www.soimort.org/you-get>

GitHub地址:<https://github.com/soimort/you-get>

M
Mort Yao 已提交
184
## 特点
M
Mort Yao 已提交
185 186 187

### 说明

M
Mort Yao 已提交
188
You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/youku-lixian)用Python 3改写而成,增加了以下功能:
M
Mort Yao 已提交
189

M
Mort Yao 已提交
190
* 支持YouTube、Vimeo等国外视频网站
M
Mort Yao 已提交
191 192 193
* 支持断点续传
* 可设置HTTP代理

M
Mort Yao 已提交
194
### 支持的站点(截至目前)
M
Mort Yao 已提交
195

M
Mort Yao 已提交
196
已实现对以下视频站点的支持,以后会陆续增加(・∀・)
M
Mort Yao 已提交
197 198

* YouTube <http://www.youtube.com>
M
Mort Yao 已提交
199
* Vimeo <http://vimeo.com>
M
Mort Yao 已提交
200 201
* 优酷 <http://www.youku.com>
* 土豆 <http://www.tudou.com>
M
Mort Yao 已提交
202
* 音悦台 <http://www.yinyuetai.com>
M
Mort Yao 已提交
203 204 205
* AcFun <http://www.acfun.tv>
* bilibili <http://www.bilibili.tv>
* CNTV <http://www.cntv.cn>
M
Mort Yao 已提交
206
* 凤凰视频 <http://v.ifeng.com>
M
Mort Yao 已提交
207 208 209 210 211 212
* 爱奇艺 <http://www.iqiyi.com>
* 酷6网 <http://www.ku6.com>
* PPTV <http://www.pptv.com>
* 新浪视频 <http://video.sina.com.cn>
* 搜狐视频 <http://tv.sohu.com>
* 56网 <http://www.56.com>
M
Mort Yao 已提交
213

M
Mort Yao 已提交
214 215 216 217 218 219
## 依赖

* [Python 3](http://www.python.org/download/releases/)
* __(可选)__ [FFmpeg](http://ffmpeg.org)
    * 用于转换与合并视频文件。

M
Mort Yao 已提交
220
## 安装说明
M
Mort Yao 已提交
221

M
Mort Yao 已提交
222
(以下命令格式均以Linux shell为例)
M
Mort Yao 已提交
223

224
### 1. 通过[Pip](http://www.pip-installer.org/)安装:
M
Mort Yao 已提交
225

M
Mort Yao 已提交
226
    $ pip install you-get
M
Mort Yao 已提交
227 228 229 230 231 232 233
    
   检查安装是否成功:
    
    $ you-get -V

### 2. 通过[EasyInstall](http://pypi.python.org/pypi/setuptools)安装:

M
Mort Yao 已提交
234
    $ easy_install you-get
M
Mort Yao 已提交
235 236 237 238 239
    
   检查安装是否成功:
    
    $ you-get -V

M
Mort Yao 已提交
240 241 242
### 3. 从Git安装:

    $ git clone git://github.com/soimort/you-get.git
M
Mort Yao 已提交
243 244 245
    
   在不安装的情况下直接使用脚本:
    
M
Mort Yao 已提交
246
    $ cd you-get/
M
Mort Yao 已提交
247 248 249 250 251 252 253 254 255 256 257 258 259 260
    $ ./you-get -V
    
   若要将Python package安装到系统默认路径,执行:
    
    $ make install
    
   或:(适用于Windows)
    
    > setup.py install
    
   检查安装是否成功:
    
    $ you-get -V

M
Mort Yao 已提交
261 262 263 264
### 4. 直接下载(从<https://github.com/soimort/you-get/zipball/master>):
    
    $ wget -O you-get.zip https://github.com/soimort/you-get/zipball/master
    $ unzip you-get.zip
M
Mort Yao 已提交
265 266 267
    
   在不安装的情况下直接使用脚本:
    
M
Mort Yao 已提交
268
    $ cd soimort-you-get-*/
M
Mort Yao 已提交
269 270 271 272 273 274 275 276 277 278 279 280 281 282
    $ ./you-get -V
    
   若要将Python package安装到系统默认路径,执行:
    
    $ make install
    
   或:(适用于Windows)
    
    > setup.py install
    
   检查安装是否成功:
    
    $ you-get -V

M
Mort Yao 已提交
283 284 285
### 5. 从[AUR (Arch User Repository)](http://aur.archlinux.org/)安装:

   点击[这里](https://aur.archlinux.org/packages.php\?ID=62576)
M
Mort Yao 已提交
286

M
Mort Yao 已提交
287
## 使用方法示例
M
Mort Yao 已提交
288

M
Mort Yao 已提交
289
### 如何下载视频
M
Mort Yao 已提交
290 291 292

显示视频信息,但不进行下载(`-i``--info`选项):

M
Mort Yao 已提交
293
    $ you-get -i http://www.yinyuetai.com/video/463772
M
Mort Yao 已提交
294 295 296

下载视频:

M
Mort Yao 已提交
297
    $ you-get http://www.yinyuetai.com/video/463772
M
Mort Yao 已提交
298 299 300

下载多个视频:

M
Mort Yao 已提交
301
    $ you-get http://www.yinyuetai.com/video/463772 http://www.yinyuetai.com/video/471500
M
Mort Yao 已提交
302 303 304 305

若当前目录下已有与视频标题同名的文件,下载时会自动跳过。若有同名的`.download`临时文件,程序会从上次中断处开始下载。
如要强制重新下载该视频,可使用`-f``--force`)选项:

M
Mort Yao 已提交
306
    $ you-get -f http://www.yinyuetai.com/video/463772
M
Mort Yao 已提交
307 308 309

`-l``--playlist`)选项用于下载播放列表(只对某些网站适用):

M
Mort Yao 已提交
310
    $ you-get -l http://www.youku.com/playlist_show/id_5344313.html
M
Mort Yao 已提交
311

M
Mort Yao 已提交
312 313
__注:从0.1.3以后的版本起,`-l`选项不再必须。You-Get可以自动识别并处理播放列表的下载。__

M
Mort Yao 已提交
314 315
指定视频文件的下载目录:

M
Mort Yao 已提交
316
    $ you-get -o ~/Downloads http://www.yinyuetai.com/video/463772
M
Mort Yao 已提交
317 318 319

显示详细帮助:

M
Mort Yao 已提交
320
    $ you-get -h
M
Mort Yao 已提交
321 322 323 324 325

### 如何设置代理

默认情况下,Python自动使用系统的代理配置。可以通过环境变量`http_proxy`来设置系统的HTTP代理。

M
Mort Yao 已提交
326
`-x``--http-proxy`)选项用于手动指定You-Get所使用的HTTP代理。例如:GoAgent的代理服务器是`http://127.0.0.1:8087`,则通过该代理下载某YouTube视频的命令是:
M
Mort Yao 已提交
327

M
Mort Yao 已提交
328
    $ you-get -x 127.0.0.1:8087 http://www.youtube.com/watch?v=KbtO_Ayjw0M
M
Mort Yao 已提交
329 330 331

Windows下的自由门等翻墙软件会自动设置系统全局代理,因此无需指定HTTP代理即可下载YouTube视频:

M
Mort Yao 已提交
332
    $ you-get http://www.youtube.com/watch?v=KbtO_Ayjw0M
M
Mort Yao 已提交
333 334 335

如果不希望程序在下载过程中使用任何代理(包括系统的代理配置),可以显式地指定`--no-proxy`选项:

M
Mort Yao 已提交
336
    $ you-get --no-proxy http://v.youku.com/v_show/id_XMjI0ODc1NTc2.html
M
Mort Yao 已提交
337 338 339

### 断点续传

M
Mort Yao 已提交
340
下载未完成时被中止(因为`Ctrl+C`终止程序或者网络中断等原因),在目标路径中会有一个扩展名为`.download`的临时文件。
M
Mort Yao 已提交
341 342 343

下次运行只要在目标路径中找到相应的`.download`临时文件,程序会自动从中断处继续下载。(除非指定了`-f`选项)

M
Mort Yao 已提交
344
## 使用Python 2?
M
Mort Yao 已提交
345 346 347 348 349

优酷等国内视频网站的下载,请移步:[iambus/youku-lixian](https://github.com/iambus/youku-lixian)

YouTube等国外视频网站的下载,请移步:[rg3/youtube-dl](https://github.com/rg3/youtube-dl)

M
Mort Yao 已提交
350
## 许可证
M
Mort Yao 已提交
351

M
Mort Yao 已提交
352
You-Get在[MIT License](https://raw.github.com/soimort/you-get/master/LICENSE.txt)下发布。