用python做youtube自动化下载器 思路

Posted Eritque arcus

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用python做youtube自动化下载器 思路相关的知识,希望对你有一定的参考价值。

用python做youtube自动化下载器

根据 savefrom条例
本实例及教程只用于学习交流用,权利归savefrom.net所有

0. 思路

使用python从savefrom平台上获取指定youtube视频下载链接进行下载,不过savefrom的数据是用javascript加密的,这也是难度所在
本教程主要介绍制作思路,下一篇会介绍制作python
本教程根据stakoverflow 回答制作

1.准备

i.savfrom.net

一个网站可以免费下载youtube视频

2. 探索并规划获取方式

i.总览

打开https://en.savefrom.net/1-youtube-video-downloader-4/可以看见页面主要就一个from表单输入框和提交按钮组成

ii. 获取该网页取到下载url的请求

在chrome或其他浏览器按F12打开开发者控制台,点开Network选项卡

接下来模拟正常的用户流程,在输入框输入一个youtube视频地址,比如这个https://www.youtube.com/watch?v=IjJmTeBSEzU,然后点击Download提交url获取下载url,然后我们可以发现下面已经出现了下载链接。然后我们在network选项卡内可以发现一个特殊的申请saveform.php(如果没发现可以多提交几次,就会发现每次提交都有这个请求或者看html里的form元素的src地址就是savform.php)

我们就可以确定关于下载链接会出现在这个请求的返回值内。

iii. 在本地获取请求

在本地用IDE的http工具或者python构建出post请求代码,笔者用的是pycharm的httpClient(按2下左Shift,然后输入Tools,然后回车进入菜单,然后点击httpClient下的第一个)

把请求里第二个headers的内容全部复制然后格式化然后构建post请求

然后把下面的formdata的参数也复制进来,记得和headers换行

POST https://en.savefrom.net/savefrom.php
cache-Control: no-cache
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9,en;q=0.8
content-type: application/x-www-form-urlencoded
cookie: lang=en; country=CN; uid=fd94a82a406a8dd4; sfHelperDist=72; reference=14; clickads-e2=90; poropellerAdsPush-e=63; promoBlock=64; helperWidget=92; helperBanner=42; framelessHdConverter=68; inpagePush2=68; popupInOutput=9; _ga=GA1.2.799702638.1610248969; _gid=GA1.2.628904587.1610248969; PHPSESSID=4aojkm49oj7h3de65pekqii337; x-requested-with=; PHPSESSUD=122fb7e10af37e23d99e896fd188744f; _gat_helperWidget=1; _gat_inpagePush2=1
origin: https://en.savefrom.net
pragma: no-cache
referer: https://en.savefrom.net/1-youtube-video-downloader-4/
sec-ch-ua: "Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"
sec-ch-ua-mobile: ?0
sec-fetch-dest: iframe
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36

sf_url=https://www.youtube.com/watch?v=YPvtz1lHRiw&sf_submit=&new=1&lang=en&app=&country=cn&os=Windows&browser=Chrome

如果配置没错,这个时候你运行后会显示出和在浏览器里一样的结果,然后可以发现参数里的sf_url就是需要下载的youtube地址

iv.解析请求结果

把取到的结果保存在本地然后在浏览器打开保存的本地文件,然后弹出一个弹窗后会发现这个页面什么都没有,但其实如果你在console输入window会发现有很多变量和函数,其中就有我们需要的加密后的url和解密函数

经过弹窗提示我们可以发现是这个html的js发现了我们不在他的网站上然后删除了显示下载url的代码所以我们才什么都看不到,打开source选项卡或者用IDE打开源代码查看

扫一下这个源代码,我们可以看见一些加密解密函数,被加密的乱码信息,哈希对照表,和一些奇怪的赋值操作,如图

我们可以看见,js部分由一个大闭包组成

  • 第3行到第9行是声明函数
  • 第10行是给$b赋值this也就是window
  • 第11到第13行是赋值3个变量
  • 第14,15行是对变量执行一些操作,这个也是我们重点关注的,毕竟执行加密,解密方法只可能在这

第14,15行格式化后如下

this.$d = $d;
this.$a = $a;
this.$e = $e;
this.$k = $k;
this.$c = $c;
$c = _q($c);
$c = _b($c);
_m($b, $c);

去掉前5行没有意义的变量互换值,加密解密函数存在的范围就在最后3行

$c = _q($c);
$c = _b($c);
_m($b, $c);

然后开始一个个试
先在console里输入第一行

然后就出现了明文,所以我们就确定这个是我们需要的解密函数
接下来输入第二行

发现出现了和上面一模一样的明文,所以这个也是解密函数
接下来输入第三行
发现这个执行了那段代码,这个应该是执行函数,所以我们现在就找到了解密函数位于js部分的最后几行

v.解析解密后的结果

console里用解密函数解密出的结果复制出来会得到一个JavaScript脚本

(function()
function del()while(document.body.firstChild)document.body.removeChild(document.body.firstChild);;
if(window.location.hostname.search(/(?:^|\\.|@)(savefrom\\.net|sfrom\\.net|savefrom\\.com\\.au|51\\.159\\.57\\.158|(?:fe\\d*|test)-front\\.sf-apps\\.com)$/i) == -1)

alert('Please go to http://savefrom.net/ to get direct links');
del();
return;


function showResult()
var success = false;
try

var d = window.parent.document;
if(d && d.getElementById)

var e = d.getElementById('sf_result');
if(e && e.innerHTML)

window.parent.sf.finishRequest(true);;
e.innerHTML = '';
window.parent.sf.videoResult.show("id":"YPvtz1lHRiw","cipher":false,"meta":"title":"The Most Genius Plays in Football","source":"https:\\/\\/www.youtube.com\\/watch?v=YPvtz1lHRiw","duration":"7:03","tags":"lionel messi,football tiki taka,football highlight,football team plays,kevin de bruyne,mesut \\u00f6zil,paul pogba,cristiano ronaldo,adama traore,luka modric,toni kroos,andres iniesta,kylian mbappe,neymar jr,zlatan ibrahimovic,franck ribery,paulo dybala,philippe coutinho,robert lewandowski,barcelona,real madrid,liverpool,manchester city","thumb":"https:\\/\\/i.ytimg.com\\/vi\\/YPvtz1lHRiw\\/hqdefault.jpg","itags":["18","22","133","134","135","136","137","140","160","242","243","244","247","248","249","250","251","278"],"video_quality":["1080","720","480","360","240","144"],"url":["url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"360","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":false,"quality":"360","audio":false,"no_audio":false,"itag":"18","filesize":35202709,"attr":"title":"video format: 360","class":"","info_token":"0c41b67f74ccb97e50f2e64fe5f4625a","url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D&title=The%20Most%20Genius%20Plays%20in%20Football","name":"MP4","subname":"720","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":true,"quality":"720","audio":false,"no_audio":false,"itag":"22","attr":"title":"video format: 720","class":"","info_token":"674fa89ee246148990b3f36e750a5d32","url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"1080","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4 dash","ext":"mp4","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"137","filesize":177708494,"attr":"title":"video format: 1080 (without audio)","class":"no-audio","info_token":"6816215e43020185bb429874c33f1f73","url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"WEBM","subname":"1080","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"webm dash","ext":"webm","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"248","filesize":117037047,"attr":"title":"video format: 1080 (without audio)","class":"no-audio","info_token":"43e803aa40437c9930975615121cc2c5"],"hosting":101,"srv":"s30","sd":null,"hd":null);;
window.parent.sf.enableElement('sf_submit', true);
success=true;



catch(err)

del();
if(!success)

var alt = '';
if(alt) alert(alt);



try 
if (typeof navigator.permissions != 'undefined') 
navigator.permissions.query(name:'notifications').then(function(permissionStatus) 
if(Notification.permission === 'denied' && permissionStatus.state === 'prompt') 
 else 
showResult();

);
 else 
showResult();


catch (err) 
showResult();

)();

我们可以发现里面有个del()删除函数,这就是为什么我们看不到这一段代码在执行后
因为被window.location.hostname.search(/(?:^|\\.|@)(savefrom\\.net|sfrom\\.net|savefrom\\.com\\.au|51\\.159\\.57\\.158|(?:fe\\d*|test)-front\\.sf-apps\\.com)$/i) == -1检查出不是在他的网站上跑的所以就执行弹窗和del()把解密后的东西删除了
仔细检查这段代码可以发现这一行

window.parent.sf.videoResult.show("id":"YPvtz1lHRiw","cipher":false,"meta":"title":"The Most Genius Plays in Football","source":"https:\\/\\/www.youtube.com\\/watch?v=YPvtz1lHRiw","duration":"7:03","tags":"lionel messi,football tiki taka,football highlight,football team plays,kevin de bruyne,mesut \\u00f6zil,paul pogba,cristiano ronaldo,adama traore,luka modric,toni kroos,andres iniesta,kylian mbappe,neymar jr,zlatan ibrahimovic,franck ribery,paulo dybala,philippe coutinho,robert lewandowski,barcelona,real madrid,liverpool,manchester city","thumb":"https:\\/\\/i.ytimg.com\\/vi\\/YPvtz1lHRiw\\/hqdefault.jpg","itags":["18","22","133","134","135","136","137","140","160","242","243","244","247","248","249","250","251","278"],"video_quality":["1080","720","480","360","240","144"],"url":["url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"360","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":false,"quality":"360","audio":false,"no_audio":false,"itag":"18","filesize":35202709,"attr":"title":"video format: 360","class":"","info_token":"0c41b67f74ccb97e50f2e64fe5f4625a","url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D&title=The%20Most%20Genius%20Plays%20in%20Football","name":"MP4","subname":"720","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":true,"quality":"720","audio":false,"no_audio":false,"itag":"22","attr":"title":"video format: 720","class":"","info_token":"674fa89ee246148990b3f36e750a5d32","url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"1080","info_url":"https:\\/\\/r4---sn-25glene7.googlevideo.com\\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&am

以上是关于用python做youtube自动化下载器 思路的主要内容,如果未能解决你的问题,请参考以下文章

Python能用来做啥?

python能干啥

Python可以用来干啥

用Python30秒自动获取指定关键词的国际论文?思路清奇的我是这样做的......

python爬虫实战——5分钟做个图片自动下载器

python笔试题42-69