Python You-Get 网站资源下载工具

You-Get 是一个命令行程序,提供便利的方式来下载网络上的媒体信息,比如下载B站视频

参考资料

You-Get中文说明

安装

以下为依赖项:

  • Python 3
  • FFmpeg (强烈推荐)

通过 pipenv 安装:

1
pipenv install you-get

通过 pip3 安装:

1
2
pip3 install ffmpeg -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install you-get -i https://pypi.tuna.tsinghua.edu.cn/simple

下载B站视频

以下载动漫 干物妹!小埋 OVA 为例

通过 --info/-i 参数查看所有可用画质与格式

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
$ you-get -i 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'
you-get: This bangumi currently has 2 videos. (use --playlist to download all videos.)
site: Bilibili
title: 干物妹!小埋 OVA:第1话 小埋、再一次!
streams: # Available quality and codecs
[ DASH ] ____________________________________
- format: dash-flv360
container: mp4
quality: 流畅 360P
size: 71.5 MiB (74963749 bytes)
# download-with: you-get --format=dash-flv360 [URL]

- format: dash-flv480
container: mp4
quality: 清晰 480P
size: 67.2 MiB (70501303 bytes)
# download-with: you-get --format=dash-flv480 [URL]

- format: dash-flv720
container: mp4
quality: 高清 720P
size: 67.2 MiB (70472724 bytes)
# download-with: you-get --format=dash-flv720 [URL]

[ DEFAULT ] _________________________________
- format: flv720
container: flv
quality: 高清 720P
size: 97.1 MiB (101827620 bytes)
# download-with: you-get --format=flv720 [URL]

- format: flv360
container: flv
quality: 流畅 360P
size: 71.9 MiB (75362207 bytes)
# download-with: you-get --format=flv360 [URL]

上面输出带有 DEFAULT 的为默认画质,如果认同该画质,就下载:

1
2
3
4
5
6
7
8
9
10
11
12
13
$ you-get 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'
you-get: This bangumi currently has 2 videos. (use --playlist to download all videos.)
site: Bilibili
title: 干物妹!小埋 OVA:第1话 小埋、再一次!
stream:
- format: flv720
container: flv
quality: 高清 720P
size: 97.1 MiB (101827620 bytes)
# download-with: you-get --format=flv720 [URL]

Downloading 干物妹!小埋 OVA:第1话 小埋、再一次!.flv ...
4.1% ( 4.0/ 97.1MB) ├██──────────────────────────────────────┤[1/1] 178 kB/s

使用其它选项下载

# download-with: 后面的 you-get --format=flv360 [URL]

1
$ you-get --format=flv360 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'

设置输出路径或文件名

使用 --output-dir/-o 设定路径, --output-filename/-O 设定输出文件名:

1
you-get -o ./Videos -O name 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'

通过 --playlist 参数下载整个视频选集

1
you-get -o ./Videos --playlist 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'

加载cookie

并非所有视频可供任何人观看。如果需要登录以观看 (例如, 私密视频), 可能必须将浏览器cookie通过 --cookies/-c 加载入 you-get

1
you-get -c cookies文件路径 'https://www.bilibili.com/bangumi/play/ep84999?from=search&seid=8460366586925667623'

支持两种cookie格式:Mozilla cookies.sqlite 和 Netscape cookies.txt

说明

付费、会员视频一般下载不了

官网文档指出:如果你使用本软件进行盗版行为,或者非法行径,作者不为你负责,我们仅提供代码,如何使用请自行考虑