想要下载各大视频平台的视频?可以使用这个方法抓取M3U8,再使用M3U8下载器下载
使用方法
- 收藏代码,这里以爱奇艺和腾讯为例
- 将超链接拖拽至收藏夹
- 复制代码,手动添加
- 将超链接拖拽至收藏夹
- 在视频页面点击代码
爱奇艺视频
超链接:爱奇艺视频
javascript:try{var info=playerObject._player._core._movieinfo.originalData.data.program.video;info.forEach(function(item,index){if(item._selected){var m3u8Content="";if(item.m3u8==undefined){try{if(typeof(eval(cmd5x))=="function"){}}catch(e){var req1=new XMLHttpRequest();req1.open("GET","https://static.iqiyi.com/js/common/f6a3054843de4645b34d205a9f377d25.js",false);req1.onload=function(){var script=document.createElement("script");script.text=req1.responseText;document.getElementsByTagName("head")[0].appendChild(script)};req1.send(null)}var fs=item.fs;var content="#EXTM3U\n";fs.forEach(function(fs_i,fs_index){var url=fs_i.l;var prefix="https://data.video.iqiyi.com/videos";var api=prefix+url;try{var t=playerObject._player._core._movieinfo.originalData.data.boss.data.t;api=prefix+url+"&cross-domain=1&t="+t+"&QY00001="+/qd_uid=(\d+)/g.exec(url)[1]+"&ib=4&ptime=0&ibt="+cmd5x(t+/\/(\w{10,})/g.exec(url)[1])}catch(err){}var req=new XMLHttpRequest();req.overrideMimeType("application/json");req.open("GET",api,false);req.onload=function(){var jsonResponse=JSON.parse(req.responseText);content+="#EXTINF:0\n"+jsonResponse["l"]+"\n"};req.send(null)});content+="#EXT-X-ENDLIST";m3u8Content=content}else{m3u8Content=item.m3u8}var blob=new Blob([m3u8Content],{type:"text/plain"});var url=URL.createObjectURL(blob);var title=(document.title.indexOf("-")!=-1?document.title.substring(0,document.title.indexOf("-")):document.title.replace(/\s/,""))+"_"+item.scrsz+"_"+(item.code==2?"H264":"H265")+"_"+document.getElementsByClassName("iqp-time-dur")[0].innerText.replace(/:/,".")+"_"+(item.vsize/1024/1024).toFixed(2)+"MB.m3u8";var aLink=document.createElement("a");aLink.href=url;aLink.download=title;aLink.style.display="none";var event;if(window.MouseEvent){event=new MouseEvent("click")}else{event=document.createEvent("MouseEvents");event.initMouseEvent("click",true,false,window,0,0,0,0,0,false,false,false,false,0,null)}aLink.dispatchEvent(event)}})}catch(err){var info1=playerObject._player.package.engine.adproxy.engine.movieinfo.vidl;info1.forEach(function(item1,index1){if(item1.responseData!=undefined){var info=item1.responseData.data.program.video;info.forEach(function(item,index){if(item._selected){var m3u8Content="";if(item.m3u8==undefined){try{if(typeof(eval(cmd5x))=="function"){}}catch(e){var req1=new XMLHttpRequest();req1.open("GET","https://static.iqiyi.com/js/common/f6a3054843de4645b34d205a9f377d25.js",false);req1.onload=function(){var script=document.createElement("script");script.text=req1.responseText;document.getElementsByTagName("head")[0].appendChild(script)};req1.send(null)}var fs=item.fs;var content="#EXTM3U\n";fs.forEach(function(fs_i,fs_index){var url=fs_i.l;var prefix="https://data.video.iqiyi.com/videos";var api=prefix+url;try{var t=playerObject._player.package.engine.adproxy.engine.movieinfo.current.boss.data.t;api=prefix+url+"&cross-domain=1&t="+t+"&QY00001="+/qd_uid=(\d+)/g.exec(url)[1]+"&ib=4&ptime=0&ibt="+cmd5x(t+/\/(\w{10,})/g.exec(url)[1])}catch(err){console.error(err)}var req=new XMLHttpRequest();req.overrideMimeType("application/json");req.open("GET",api,false);req.onload=function(){var jsonResponse=JSON.parse(req.responseText);content+="#EXTINF:0\n"+jsonResponse["l"]+"\n"};req.send(null)});content+="#EXT-X-ENDLIST";m3u8Content=content}else{m3u8Content=item.m3u8}var blob=new Blob([m3u8Content],{type:"text/plain"});var url=URL.createObjectURL(blob);var title=(document.title.indexOf("-")!=-1?document.title.substring(0,document.title.indexOf("-")):document.title.replace(/\s/,""))+"_"+item.scrsz+"_"+(item.code==2?"H264":"H265")+"_"+document.getElementsByClassName("iqp-time-dur")[0].innerText.replace(/:/,".")+"_"+(item.vsize/1024/1024).toFixed(2)+"MB.m3u8";/*nilaoda*/var aLink=document.createElement("a");aLink.href=url;aLink.download=title;aLink.style.display="none";var event;if(window.MouseEvent){event=new MouseEvent("click")}else{event=document.createEvent("MouseEvents");event.initMouseEvent("click",true,false,window,0,0,0,0,0,false,false,false,false,0,null)}aLink.dispatchEvent(event)}})}})}
腾讯视频
超链接:腾讯视频
javascript:var a=prompt(PLAYER._DownloadMonitor.context.dataset.title,PLAYER._DownloadMonitor.context.dataset.ckc?PLAYER._DownloadMonitor.context.dataset.currentVideoUrl:PLAYER._DownloadMonitor.context.dataset.currentVideoUrl.replace(/:.*qq.com/g,"://defaultts.tc.qq.com/defaultts.tc.qq.com"));
优酷视频
超链接:优酷视频
javascript:var url;var size=0;Array.from(videoPlayer.getData()._playlistData.stream).forEach(function(element,index,array){if(element.audio_lang==videoPlayer.getConfig().language&&element.size>size){url=element.m3u8_url;size=element.size}});/*nilaoda*/var a=prompt(videoPlayer.getData()._videoData.title+"_"+videoPlayer.getConfig().language+"_"+(size/1024/1024).toFixed(2)+"MB",url);
搜狐视频
超链接:搜狐视频
javascript:var dur=document.getElementsByClassName("x-time-duration")[0].innerText;var ti=document.getElementById("vinfobox").getElementsByTagName("h2")[0].innerText;var dfn=document.getElementsByClassName("x-resolution-btn")[0].innerText;var content="#EXTM3U\n";_player.p2pkernel.dispatchUrlArr.forEach(function(item,index){var url=item["0"];$.ajaxSettings.async=false;$.get(url,function(data,status){content+="#EXTINF:0\n"+data["servers"][0]["url"]+"\n"});$.ajaxSettings.async=true});content+="#EXT-X-ENDLIST";var blob=new Blob([content],{type:"text/plain"});var url=URL.createObjectURL(blob);var aLink=document.createElement("a");aLink.href=url;aLink.download=ti+"_"+dfn+"_"+dur.replace(/:/,".")+".m3u8";/*nilaoda*/aLink.style.display="none";var event;if(window.MouseEvent){event=new MouseEvent("click")}else{event=document.createEvent("MouseEvents");event.initMouseEvent("click",true,false,window,0,0,0,0,0,false,false,false,false,0,null)}aLink.dispatchEvent(event)