you-get介绍

一、安装

更多方式请参考you-get GitHub主页

环境依赖

以下为必要配置:

方法 1: 通过 pip 安装(Mac/Windows)

首先配置python3环境,然后通过pip命令直接安装you-get,如果电脑只有python3一个版本,则使用pip install you-get即可,如果有python2,则使用pip3命令,即pip3 install you-get

The official release of you-get is distributed on PyPI, and can be installed easily from a PyPI mirror via the pip package manager. Note that you must use the Python 3 version of pip:

pip3 install you-get

方法 2: Homebrew (Mac only)

You can install you-get easily via:

1
brew install you-get

二、简单的快速上手使用方式

2.1 查询视频/图片等信息

1
you-get -i url

2.2 下载视频/图片等

  • 直接以默认文件名下载到当前文件夹下
1
you-get  --itag=18(目标质量)  url  
  • 修改路径及文件名
    -o 保存的文件夹地址, -O 保存的文件名
    Use the --output-dir/-o option to set the path, and --output-filename/-O to set the name of the downloaded file:
1
you-get -o ~/Videos -O zoo.webm 'https://www.youtube.com/watch?v=jNQXAC9IVRw'

三、其他用法

3.1 下载其他能下载的

If you already have the URL of the exact resource you want, you can download it directly with:

1
2
3
4
5
6
7
8
$ you-get https://stallman.org/rms.jpg
Site: stallman.org
Title: rms
Type: JPEG Image (image/jpeg)
Size: 0.06 MiB (66482 Bytes)

Downloading rms.jpg ...
100.0% ( 0.1/0.1 MB) ├████████████████████████████████████████┤[1/1] 127 kB/s

Otherwise, you-get will scrape the web page and try to figure out if there’s anything interesting to you:

1
2
3
4
5
6
7
8
9
10
11
12
13
$ you-get http://kopasas.tumblr.com/post/69361932517
Site: Tumblr.com
Title: kopasas
Type: Unknown type (None)
Size: 0.51 MiB (536583 Bytes)

Site: Tumblr.com
Title: tumblr_mxhg13jx4n1sftq6do1_1280
Type: Portable Network Graphics (image/png)
Size: 0.51 MiB (536583 Bytes)

Downloading tumblr_mxhg13jx4n1sftq6do1_1280.png ...
100.0% ( 0.5/0.5 MB) ├████████████████████████████████████████┤[1/1] 22 MB/s

Note:

  • This feature is an experimental one and far from perfect. It works best on scraping large-sized images from popular websites like Tumblr and Blogger, but there is really no universal pattern that can apply to any site on the Internet.

3.2 直接观看视频

Use the --player/-p option to feed the video into your media player of choice, e.g. mpv or vlc, instead of downloading it:

1
you-get -p vlc 'https://www.youtube.com/watch?v=jNQXAC9IVRw'

Or, if you prefer to watch the video in a browser, just without ads or comment section:

1
you-get -p chromium 'https://www.youtube.com/watch?v=jNQXAC9IVRw'

3.3 Proxy settings

You may specify an HTTP proxy for you-get to use, via the --http-proxy/-x option:

1
you-get -x 127.0.0.1:8087 'https://www.youtube.com/watch?v=jNQXAC9IVRw'

However, the system proxy setting (i.e. the environment variable http_proxy) is applied by default. To disable any proxy, use the --no-proxy option.

3.4 Search on Google Videos and download

You can pass literally anything to you-get. If it isn’t a valid URL, you-get will do a Google search and download the most relevant video for you. (It might not be exactly the thing you wish to see, but still very likely.)

1
you-get "Richard Stallman eats"

四、示例

Download a video(摘录自官网)

When you get a video of interest, you might want to use the --info/-i option to see all available quality and formats:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$ you-get -i 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
site: YouTube
title: Me at the zoo
streams: # Available quality and codecs
[ DASH ] ____________________________________
- itag: 242
container: webm
quality: 320x240
size: 0.6 MiB (618358 bytes)
# download-with: you-get --itag=242 [URL]

- itag: 395
container: mp4
quality: 320x240
size: 0.5 MiB (550743 bytes)
# download-with: you-get --itag=395 [URL]

- itag: 133
container: mp4
quality: 320x240
size: 0.5 MiB (498558 bytes)
# download-with: you-get --itag=133 [URL]

- itag: 278
container: webm
quality: 192x144
size: 0.4 MiB (392857 bytes)
# download-with: you-get --itag=278 [URL]

- itag: 160
container: mp4
quality: 192x144
size: 0.4 MiB (370882 bytes)
# download-with: you-get --itag=160 [URL]

- itag: 394
container: mp4
quality: 192x144
size: 0.4 MiB (367261 bytes)
# download-with: you-get --itag=394 [URL]

[ DEFAULT ] _________________________________
- itag: 43
container: webm
quality: medium
size: 0.5 MiB (568748 bytes)
# download-with: you-get --itag=43 [URL]

- itag: 18
container: mp4
quality: small
# download-with: you-get --itag=18 [URL]

- itag: 36
container: 3gp
quality: small
# download-with: you-get --itag=36 [URL]

- itag: 17
container: 3gp
quality: small
# download-with: you-get --itag=17 [URL]

By default, the one on the top is the one you will get. If that looks cool to you, download it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ you-get 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
site: YouTube
title: Me at the zoo
stream:
- itag: 242
container: webm
quality: 320x240
size: 0.6 MiB (618358 bytes)
# download-with: you-get --itag=242 [URL]

Downloading Me at the zoo.webm ...
100% ( 0.6/ 0.6MB) ├██████████████████████████████████████████████████████████████████████████████┤[2/2] 2 MB/s
Merging video parts... Merged into Me at the zoo.webm

Saving Me at the zoo.en.srt ... Done.

(If a YouTube video has any closed captions, they will be downloaded together with the video file, in SubRip subtitle format.)

Or, if you prefer another format (mp4), just use whatever the option you-get shows to you:

1
you-get --itag=18 'https://www.youtube.com/watch?v=jNQXAC9IVRw'