鉴于上次You-get教程的介绍写到后面写不下去了。这次,简洁一点,不写那么详细。就一个简单的入门介绍。
一、绪论
ykdl是基于You-get开发的一个更适合国内用户使用的开源软件。因为是一个命令行软件,所以全平台可用(Win、Mac、linux等通通都可以)。同样基于 Python 3 。几乎可以下载网络上任何可以看的视频、可以听的音乐、可以看的图片。 已测试支持的网站有腾讯、优酷、网易云等 (因为我自己基本上都是用的IDM下载)。
二、准备工作
跟You-get一样需要以下软件作为前提
1、Python 3 (这是一个脚本语言,但是在这里我们可以很不负责任地把它理解为一个应用商店)
2、FFmpeg (这是一个开源的格式工具,几乎所有的格式转换软件都内置了它。它在ykdl里的作用就是把从网络上下载下来的分段或者flv等视频转换成一个完整的MP4)
三、安装环境和软件
1、下载 并安装 Python 3
点击上面链接,找到适合自己的版本。(如果访问缓慢或者无法访问,文末提供了文件下载)
- 可以有两种方法
- (1)去官网下载,自己配置好环境。(不推荐。太麻烦,我懒得写。)
- (2)直接用Python 3 安装
Windows用户打开Cmd或者Windows PowerShell(建议不要以管理员身份打开)
Mac用户打开终端
输入下面的代码,回车。等待安装完成。
pip3 install FFmpeg
3、安装ykdl
有很多种方式,我推荐直接用下面这行代码,windows和Mac通用
pip3 install ykdl
输入上面代码,回车。等待安装完成。
PS C:\Users\ZhouShiQi> pip3 install ykdl
Collecting ykdl
Using cached https://files.pythonhosted.org/packages/dc/84/94436ac340f840d21c0b26f4437717324a11b8fc2a2c614f7bb74bb23d48/ykdl-1.6.2.tar.gz
Collecting m3u8 (from ykdl)
Downloading https://files.pythonhosted.org/packages/33/0d/afdb6289f397511f64a9ac0769e02c9bcfc62306fe73dc4f44ba673f1e38/m3u8-0.3.9-py3-none-any.whl
Collecting pycryptodome (from ykdl)
Downloading https://files.pythonhosted.org/packages/30/13/9baa64203f5e87acfcb8575aae8256be973b286928374d0ce65f934ccb69/pycryptodome-3.8.1-cp37-cp37m-win_amd64.whl (10.0MB)
100% |████████████████████████████████| 10.0MB 70kB/s
Collecting urllib3 (from ykdl)
Downloading https://files.pythonhosted.org/packages/39/ec/d93dfc69617a028915df914339ef66936ea976ef24fa62940fd86ba0326e/urllib3-1.25.2-py2.py3-none-any.whl (150kB)
100% |████████████████████████████████| 153kB 56kB/s
Collecting iso8601 (from m3u8->ykdl)
Using cached https://files.pythonhosted.org/packages/ef/57/7162609dab394d38bbc7077b7ba0a6f10fb09d8b7701ea56fa1edc0c4345/iso8601-0.1.12-py2.py3-none-any.whl
Installing collected packages: iso8601, m3u8, pycryptodome, urllib3, ykdl
Running setup.py install for ykdl ... done
Successfully installed iso8601-0.1.12 m3u8-0.3.9 pycryptodome-3.8.1 urllib3-1.25.2 ykdl-1.6.2
You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS C:\Users\ZhouShiQi>
到这里安装已经完成,接下来就是怎么使用了。
四、ykdl的使用
windows下使用cmd或者Windows PowerShell(建议不要以管理员身份打开),Mac下使用终端。
视频下载的格式如下:
ykdl 'https://v.qq.com/x/page/t066111fk0u.html'
音频下载同理。
这个语法默认下载最好画质的视频。
PS C:\Users\ZhouShiQi> ykdl 'https://v.qq.com/x/page/t066111fk0u.html'
site: 腾讯视频 (QQ)
title: 直播吧!支书
artist: None
streams:
- format: BD
container: mp4
video-profile: 蓝光;(1080P)
size: 557.3 MiB (584400736 bytes)
# download-with: ykdl --format=BD [URL]
Download: 直播吧!支书_BD part 0
Download: 直播吧!支书_BD part 1
Download: 直播吧!支书_BD part 2
Download: 直播吧!支书_BD part 3
Download: 直播吧!支书_BD part 4
Skipped: file already downloaded
Skipped: file already downloaded
Skipped: file already downloaded
Skipped: file already downloaded
Skipped: file already downloaded
Merging video 直播吧!支书_BD using ffmpeg:
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000160ae534540] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'C:\Users\ZhouShiQi\tmp32_xenj4.txt':
Duration: N/A, start: 0.000000, bitrate: 2448 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv), 1920x1072 [SAR 134:135 DAR 16:9], 2353 kb/s, SAR 127:128 DAR 1905:1072, 24 fps, 24 tbr, 24k tbn, 48 tbc
Metadata:
creation_time : 2018-05-22T08:32:54.000000Z
handler_name : TrackHandler
Stream #0:1(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 94 kb/s
Metadata:
creation_time : 2018-05-22T07:50:59.000000Z
handler_name : Sound Media Handler
Output #0, mp4, to '鐩存挱鍚э紒鏀功_BD.mp4':
Metadata:
encoder : Lavf58.17.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv), 1920x1072 [SAR 127:128 DAR 1905:1072], q=2-31, 2353 kb/s, 24 fps, 24 tbr, 24k tbn, 24k tbc
Metadata:
creation_time : 2018-05-22T08:32:54.000000Z
handler_name : TrackHandler
Stream #0:1(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 94 kb/s
Metadata:
creation_time : 2018-05-22T07:50:59.000000Z
handler_name : Sound Media Handler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000160ae5f4b40] Auto-inserting h264_mp4toannexb bitstream filter
Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000160ae5f8440] Auto-inserting h264_mp4toannexb bitstream filter+003x
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000160ae5f4b40] Auto-inserting h264_mp4toannexb bitstream filter
frame=41520 fps=0.0 q=-1.0 Lsize= 570993kB time=00:28:50.10 bitrate=2703.6kbits/s speed=1.78e+003x
video:549875kB audio:20172kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.165851%
PS C:\Users\ZhouShiQi>
使用 -i 可以查看并选择可下载的视频尺寸和格式,语法如下:
ykdl -i 'https://v.qq.com/x/page/t066111fk0u.html'
这个语法还会列出视频的真实地址,可以复制到迅雷、IDM等下载软件下载。
PS C:\Users\ZhouShiQi> ykdl -i 'https://v.qq.com/x/page/t066111fk0u.html'
site: 腾讯视频 (QQ)
title: 直播吧!支书
artist: None
streams:
- format: BD
container: mp4
video-profile: 蓝光;(1080P)
size: 557.3 MiB (584400736 bytes)
# download-with: ykdl --format=BD [URL]
Real urls:
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p709.1.mp4?vkey=D0B4D2F0DD8A1648C855C5718FA85C795B4A1CFBB76D25753FEE2E9E4257188A30511E6E7A5CB8B75C91ED8B540180ECA8110AB779705CF5A320C7FAD227B18B15B13C2DAE1FA042F0694CDB48F922CB1D0F2BA88721AE0F213EAD665D1A7169BCB78312522AB6CA
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p709.2.mp4?vkey=44859240D2B09EEF87CCA85129071DEE523F173E6736B6A337612F7FC879531F2EFC2D5677EA635ABC14802BD21D1EAF6F0887C645919E58578F7C66B2FA2D186CC4FF654F53188427CA0FD016471FABA6C89622131F164614E960B1351D49300E6CAC3AC0660971958E6DAB6767F0ED
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p709.3.mp4?vkey=A7499C772E2E82D9893BD2B8040D030512D1DF4805BDC0EFFBBD47D6B3B033CE2477CAD99FD50C743B41935F1840E20D9DED9F3FA5B9E174C566295460A232DED7A0AB7E95E42D4BB1A7D83EDEEB8BB702C4097AD8B766F00B0EDF00DD868CD97A4C4D5D9018033C2CC400DBF03F6B11
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p709.4.mp4?vkey=F3723945F40EB43993C171A906F638E860CDC09B07C2A2F74699B1E21EA6B459D3938277FBFE140F61D8A3310CA88CDEBF4DE8B9834F6D930922DE3CFC3396D293D850A7719B20C9C359ED8992CE8A972D04D25284E2D3F24EF317FDE0D34AFCB959EFE5BCBDA4DAA29E910F095A05FF
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p709.5.mp4?vkey=E2179A003C5B62BA5D1F731639A706AC2761090AE49C3A06AFA13B369797D283178BD007A9D651830493C1FFD051AD58C976D5C2311089318094F88E06A3683E8FB165EFD75B8FD6305646F3246F26D556C7A8F8B7D78C64F59D1D8119998958AF25EA99ABDCF279B35C4F1C3412A174
- format: TD
container: mp4
video-profile: 超清;(720P)
size: 307.8 MiB (322762284 bytes)
# download-with: ykdl --format=TD [URL]
Real urls:
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p701.1.mp4?vkey=4E0FEE8641A891E62FD564602C1DC5228FA8A71883CFE2BF37E0D7F0F7F48312EF44D83CFD3B2225032DCF475E223A6431B1B14EF69E9F4706A0F5C5715CE8279FC890C0B57606BE0DD585D53D6C899B63DF855755920B355BAE08BBE5BB9B914D4CEBEE2294F3405472C93F95D077A3
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p701.2.mp4?vkey=5EBCE4C114BE993D7083667C70BA186348C11608AC92B77AB3DD7CB27D17E5B346A04B64F97D6701514D333EEE3DBE3B3E44CC022AF565AC901304DD10E0A25077811E7234B5944FB4D74186EF07F466ECB21210EA5F67B4EE83589298938C9A36BFEC6F8D20C25775ECEAA9FDA40011
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p701.3.mp4?vkey=E777B32C985132B1D7847A9C29E26032A996D4F8AA7C2F4A14C6432F0E1030DB0CEDBF4C53E97389F1C95B353C0DD5822741374873E16B383D5D2A3C8E76B0BDB849B8A7368919998E5906C6813AB681BCB2506C01710CD91C585E544BE2657737DE24CD48EF12DE2E39F6A7BD4837DD
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p701.4.mp4?vkey=EEF419CD3F54939D5823B92BBDA380E9976F16F54F942AD8945C4086C1B9892D988AC83AF759F804EFC3B08EC597F0FCD671E8735320350171C972F0D21BE2E444FD887F041DB4661AA1BD71837CD242A7D251588874705F5B603FD7879243C5605087D160EF254D214BEF9A032CEFAA
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p701.5.mp4?vkey=4A61CDD33ED0616CC4A03A5FC574E3E4A39BFB96AF1744049978A4DDD8915CD458229265C1ED760C65D32DEE7E3F04E1557629A3B9DEEF5DD7E67B823989552C6DE0B6603E29DAD5E9E8BFFF081B2D506F0190E19CD88B7FE59260B9CF4AFC2505E3A2D6D75F5D41
- format: HD
container: mp4
video-profile: 高清;(480P)
size: 143.4 MiB (150416307 bytes)
# download-with: ykdl --format=HD [URL]
Real urls:
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p712.1.mp4?vkey=A2D4E6B944E0F220C759415B742F0B6648C47E61B5B5C6DB8B8C328F4FB4C4B201C4FE8C530171B3210B458F3428482C8F70FA973A6C62C79EB70E8910D01CBB0B64C1646FABBECCFB30C869E424C4266E06AA0CA806F5A9A465BF08EE12151674F1265C471F918E
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p712.2.mp4?vkey=E7CC2A1C08CDD16E373B047B97070A0DD8AD4227FF014C24ADB029B4D63D0F99B9A17531B253E18BABFD3EFC02C0777CD7F58AEC9ADA1CB59D7A42D08D818FB6B8B9B5266A6387456C88F9D1601EDD363D4CA8A97AA44DF79B40CCBEF55B218C2DF2A4205B94D60B97B58F004B41CF26
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p712.3.mp4?vkey=1A16A32BD3FAD10D539BA525B7892DD72029127BD60CC5E3AF008E9EF9FA2E196E9CB72FEB3B92BFCA4F963B002C0367A12C0005B82F9FFFD970F705F43F0859611781EA1ACB336ECF9499B9F4910D116B1F3003AB6285641C9358EB6288568FD00D4F825530F251CB663CD2BF2DEE7A
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p712.4.mp4?vkey=A0AC7C2E5E1D5293C406EF2C28E40D17C7E21077950F1CAA178721BEE4D47C8AE6A9E7234C0F14257F5E5E3A14A8580A48AC950AB48FE4867405050A6FE62F72AFF99AC9CC5E820441D7AEAAB4736806EB301A3FA0BCC6CA338BA955C286831AF7ABCAD92BDBD4C1
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p712.5.mp4?vkey=B062A5CBC13586D5524CC1FDF154B32C88802E2124FC74DEC13E2A167CAE353DF883B451088EA0F2F34A9276307E415B677D4BF613CE7865D3002B97925F1EA64F8CFF157C8F54AA048253C33B4182FA6D024CC9A58F69287264FF3CC54ED4CFDEEF28CF882480AF3300B5E14C6A39F2
- format: SD
container: mp4
video-profile: 标清;(270P)
size: 75.4 MiB (79022950 bytes)
# download-with: ykdl --format=SD [URL]
Real urls:
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p703.1.mp4?vkey=C4AC6F327C052822B2958B379E65BD3643012D8D90046E1C5796AE8283C4B2446C098EEF7E9B75822AB7DE7326E3365EAE7FBCB89FB4D12F44400ACCAAE8A81FFD6C93EA01FC028C56AE890CDF107977B0D5BF0BE7C041DF56186AF8C311FEB0CFE2D87067B401E1
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p703.2.mp4?vkey=03155773E2DDF10F3B8A0F1342CEDBD958E6E6C373B36D1EF54AA04F886DFA2B02E2257BC41CDCB70C47429C54B2CBCC3CC6916DF96A1025968D3FE4F1396FEDA6D98CF735C337C5551C09023FB28AF01D87FA51DCFB5ED39D01C6D2E2218417DF1EF7B93E34111B
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p703.3.mp4?vkey=84D7A9FFAFE5057F129074F2481435A9F1FBDB7FA388FE93AC9AAA33C07E1D7A6C5EAB8DAEA6620B53E3931D6F3463AA8E37291311D267136D85EE74E905BF6BD4A8680D378A2A92BA314A4D6856C82D25037AE855AAA90EB73B39CFFCD6B40247B8A39DC8968317630D912D7EA5E75D
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p703.4.mp4?vkey=5F6AAE09C2EBBFB2CDDF98646CD752382ED34BCFAB0BB5F75AA81112C05A9C2EF87741384B460CEC9A9E6759869ADE7CE2044467AAD5B9F409FC014E537093CD03AF2EC934B50031211FEFAD5C7268913120A95375C41E1C2463CF65F79BE6B5295C703C5B10A1A9AFE557503402D7BD
http://ugcyd.qq.com/uwMROfz2r5zAoaQXGdGnC2dfJ6nM3DInWQqp2axRinGnB-kO/t066111fk0u.p703.5.mp4?vkey=3CDA9541FE70DE85EE212498F99E55D8EE9CA26D6BE4376EEF33609342C975A3717619FB55C70788553AB8BBDC3B2B68EA1F6076BE207B80F24B96835D34A88706F3A46E25554E7BE36673197A68CA728734CE46A164A164D343C06A6F4FB74CEDEFEA859B055638
1、如上,如果我们需要下载1080蓝光的视频,则只需要
ykdl --format=BD [URL]
即 ykdl --format=BD 'https://v.qq.com/x/page/t066111fk0u.html'
2、Real urls: 后面的是真实地址可以复制到下载工具下载。这个视频里面有五个分段,所以每个清晰度后面都有五个地址。
PS C:\Users\ZhouShiQi> ykdl --format=BD 'https://v.qq.com/x/page/t066111fk0u.html'
site: 腾讯视频 (QQ)
title: 直播吧!支书
artist: None
streams:
- format: BD
container: mp4
video-profile: 蓝光;(1080P)
size: 557.3 MiB (584400736 bytes)
# download-with: ykdl --format=BD [URL]
Download: 直播吧!支书_BD part 0
Download: 直播吧!支书_BD part 1
Download: 直播吧!支书_BD part 2
Download: 直播吧!支书_BD part 3
Download: 直播吧!支书_BD part 4
100%
下载完正常情况下会将五个分段合成为一个Mp4视频。文件位置
在Win系统下一般在用户文件夹。比如上面就在 C:\Users\ZhouShiQi> 路径下面
在Mac系统下最近文件就可以找到
附件
Python_Win_x64
1 文件 24.9Mb
Python_Mac
1 文件 26.5Mb
棒棒棒,撒花✿✿✿
测试一下哈哈哈
回复测试
继续测试回复
符号测试#%#$^%&%^&
??