-
Notifications
You must be signed in to change notification settings - Fork 2
/
ytdlr.min.js
1 lines (1 loc) · 1000 Bytes
/
ytdlr.min.js
1
(()=>{let e,t="https://www.youtube.com",a="/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";async function o(o,i="en-US"){i=i.split("-");let n=await e(t+a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:{client:{hl:i[0],gl:i[1],clientName:"3",clientVersion:"16.50",clientScreen:"EMBED"},thirdParty:{embedUrl:t}},videoId:o})});if("OK"!==n.playabilityStatus.status)throw Error(n.playabilityStatus.reason);return{details:n.videoDetails,formats:[...n.streamingData.formats||[],...n.streamingData.adaptiveFormats||[]]}}"undefined"==typeof window?(e=(e,o)=>(e=new URL(e),o={...o,host:t,path:a},new Promise(((t,a)=>{let i=require(e.protocol.slice(0,-1)).request(o,((e,a="")=>{e.on("data",(e=>{a+=e})),e.on("end",(()=>t(JSON.parse(a))))}));o.body&&i.write(o.body),i.on("error",(e=>a(e))),i.end()}))),module.exports=o):(e=(e,t)=>window.fetch(e,t).then((e=>e.json())),window.ytdlr=(e,t)=>o(e||new URLSearchParams(window.location.search).get("v"),t))})();