使用you-get下载youtube视频
作者:互联网
使用you-get下载youtube视频
有时候需要从视频网站下载视频,很多软件都需要收费,最近发现一个可以免费下载视频完整开源工具you-get,支持视频网站比较多,废话不多说,先按说明搭建试试。虽然中间遇到很多坑,最终终于搞定。
1、环境搭建
下面是官网要求环境:
Prerequisites
The following dependencies are necessary:
安装python运行环境、下载FFmpeg(我这里是windows环境、下载后设置环境变量)详细步骤不在赘述。
2、安装you-get
官网介绍安装方式比较多,这里选择pip安装具体命令如下
pip3 install you-get
上面就完成you-get所有安装
3、开始使用
接着按照官网说明开始抓取视频文件,下面是官网实例:
$ 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]
执行上面脚本报如下错误:
you-get: [error] oops, something went wrong.
you-get: don't panic, c'est la vie. please try the following steps:
you-get: (1) Rule out any network problem.
you-get: (2) Make sure you-get is up-to-date.
you-get: (3) Check if the issue is already known, on
you-get: https://github.com/soimort/you-get/wiki/Known-Bugs
you-get: https://github.com/soimort/you-get/issues
you-get: (4) Run the command with '--debug' option,
you-get: and report this issue with the full output.
增加debug日志、查找wiki发现视频地址参数不能用单引号,但是视频网站参数去掉单引号,国内视频可以正常下载,youtube还是不行(需要正确上网)。继续排查可以能需要代理,安装代理
pip3 install pysocks
抓取视频信息
you-get -i https://www.youtube.com/watch?v=MAXeCR7iNmU -s 127.0.0.1:1080 --debug
显示结果成功!
127.0.0.1 1080
site: YouTube
title: 趙雷 -《無法長大》- 成都 MV (高圓圓出演)
streams: # Available quality and codecs
[ DASH ] ____________________________________
- itag: 137
container: mp4
quality: 1920x1080 (1080p)
size: 38.3 MiB (40124306 bytes)
# download-with: you-get --itag=137 [URL]
- itag: 248
container: webm
quality: 1920x1080 (1080p)
size: 36.8 MiB (38535272 bytes)
# download-with: you-get --itag=248 [URL]
- itag: 399
container: mp4
quality: 1920x1080 (1080p)
size: 34.8 MiB (36523777 bytes)
# download-with: you-get --itag=399 [URL]
- itag: 247
container: webm
quality: 1280x720 (720p)
size: 22.9 MiB (23971106 bytes)
# download-with: you-get --itag=247 [URL]
- itag: 398
container: mp4
quality: 1280x720 (720p)
size: 22.0 MiB (23097855 bytes)
# download-with: you-get --itag=398 [URL]
- itag: 244
container: webm
quality: 854x480 (480p)
size: 15.1 MiB (15818172 bytes)
# download-with: you-get --itag=244 [URL]
- itag: 136
container: mp4
quality: 1280x720 (720p)
size: 14.5 MiB (15174712 bytes)
# download-with: you-get --itag=136 [URL]
- itag: 397
container: mp4
quality: 854x480 (480p)
size: 13.6 MiB (14266089 bytes)
# download-with: you-get --itag=397 [URL]
- itag: 243
container: webm
quality: 640x360 (360p)
size: 11.5 MiB (12103730 bytes)
# download-with: you-get --itag=243 [URL]
- itag: 135
container: mp4
quality: 854x480 (480p)
size: 11.0 MiB (11578437 bytes)
# download-with: you-get --itag=135 [URL]
- itag: 396
container: mp4
quality: 640x360 (360p)
size: 10.5 MiB (10979909 bytes)
# download-with: you-get --itag=396 [URL]
- itag: 134
container: mp4
quality: 640x360 (360p)
size: 9.6 MiB (10078164 bytes)
# download-with: you-get --itag=134 [URL]
- itag: 242
container: webm
quality: 426x240 (240p)
size: 9.2 MiB (9636870 bytes)
# download-with: you-get --itag=242 [URL]
- itag: 278
container: webm
quality: 256x144 (144p)
size: 8.9 MiB (9331475 bytes)
# download-with: you-get --itag=278 [URL]
- itag: 395
container: mp4
quality: 426x240 (240p)
size: 8.5 MiB (8938549 bytes)
# download-with: you-get --itag=395 [URL]
- itag: 394
container: mp4
quality: 256x144 (144p)
size: 8.2 MiB (8616821 bytes)
# download-with: you-get --itag=394 [URL]
- itag: 133
container: mp4
quality: 426x240 (240p)
size: 8.1 MiB (8486143 bytes)
# download-with: you-get --itag=133 [URL]
- itag: 160
container: mp4
quality: 256x144 (144p)
size: 7.0 MiB (7386119 bytes)
# download-with: you-get --itag=160 [URL]
[ DEFAULT ] _________________________________
- itag: 18
container: mp4
quality: medium
size: 15.3 MiB (16014828 bytes)
# download-with: you-get --itag=18 [URL]
选择上面参数抓取视频
you-get --itag=399 https://www.youtube.com/watch?v=MAXeCR7iNmU -s 127.0.0.1:1080
视频成功下载
标签:视频,container,itag,--,get,youtube,download,quality 来源: https://www.cnblogs.com/haojinguo/p/15644837.html