Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!Doctype html><html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>YTVP</title>
- <style>
- #nxt a{
- margin: 10px;
- width: 200px;
- position: relative;
- padding: 10px;
- border: 2px solid blue;
- display: inline-block;
- }
- #nxt a img{
- width: 200px;
- }
- #v1{
- max-width: 99%;
- }
- </style>
- </head><body>
- <script type="text/javascript" id="ytvg_archive_mod.js">
- /*
- 2020-Aug-19
- YouTube video get (archive.org mod)
- archive youtube videos and watch them too
- ytInitialPlayerConfig.args.player_response
- or
- ytplayer.config.args.player_response
- */
- if(!Object.assign){
- Object.assign=function assign(oo,o2){
- for(var p in o2)oo[p]=o2[p];
- };
- }
- var chcrp=function(s){return "\\x"+s.charCodeAt(0).toString(16);},
- __vids_;
- if(self.YTVG&&Object.keys(self.YTVG.vids).length)__vids_=self.YTVG.vids;
- var _kyp=["@","a",":","c","/","^",".",";"],
- _scrm=function(s){
- var a=s.split(""),i=0,L=a.length,p;
- while(i<L){
- p=_kyp.indexOf(a[i]);
- if(p>=0){a[i]=_kyp[p&1?p-1:p+1];}
- i++;
- }
- return a.join("");
- };
- self.$B=self.$B||{};
- self.YTVG={
- "vids":__vids_||{},
- "cu1":_scrm(($B.ac="httpsc^^web;@r:hive;org^")+"web^"),
- "cu2":_scrm($B.ac+"s@ve^"),
- "yt":_scrm("httpsc^^www;youtube;:om"),
- "squ":_scrm("httpsc^^web;@r:hive;org^:dx^se@r:h^:dx?limit=50&output=json&limit=50&url="),
- "noHaz":[],
- "haz":function isArchived(adr,cb){
- if(YTVG.noHaz.indexOf(adr)>=0){cb(!1,adr);return 0;}
- var adr2=(adr.substr(0,6)=="https:")?("http"+adr.substr(5)):adr,
- xhr3=new XMLHttpRequest();
- xhr3.open("GET",YTVG.squ+encodeURIComponent(adr));
- xhr3.onload=function(){ var R=JSON.parse(xhr3.response); if(!R.length){ cb(!1,adr,4); return 0;}
- var sc=R[0].indexOf("statuscode"),L=R.length,i=L;
- while((i--)>1){
- if((R[i][sc]*1)<400){ cb(!0,adr,R[i]); i=-2; }
- }
- if(i>-1) cb(!1,adr,4);
- };
- xhr3.send();
- },
- "urlqp":function URLquerryParse(q,I){ if(I=(q.indexOf("?")+1))q=q.substr(I);
- var ubj={},a=q.split("&"),i=a.length,s,ei;
- while(i--){ei=(s=a[i]).indexOf('='); ubj[s.substr(0,ei)]=decodeURIComponent(s.substr(ei+1).replace(/\+/g," ")); }
- return ubj;
- },
- "cphrgt":function cphrgt(cb){
- var T=this,jsu=T.yt+T.basej,ongot=function(s){
- var fi='=function(a){a=a.split("");',cfi1=s.indexOf(fi),cfii=s.indexOf(fi,cfi1+1),cfi=cfii>0?cfii:cfi1,fe=';return a.join("")',
- cf=s.substr(cfi+fi.length,1000),cfo=cf.substr(0,cf.indexOf("."))+"={",
- cfos=s.substr(s.indexOf(cfo),1000);
- eval(T.sig_enc_obj=cfos.substr(0,cfos.indexOf("}};")+3));
- eval("var _cf__"+fi+cf.substr(0,cf.indexOf(fe)+fe.length)+";};");
- T.sig_par=_cf__;
- if(typeof cb=="function")cb();
- };
- T.haz(jsu,function(b){
- var xhr2=new XMLHttpRequest();
- xhr2.open("GET",(b?T.cu1:T.cu2)+jsu);
- xhr2.onload=function(){ ongot(xhr2.response); };
- xhr2.send();
- });
- },
- "gJSON":function(s1,pnm){
- var obL=pnm.split(","),ind=-1,i=0,obj1;
- while(ind<0&&i<obL.length){ind=s1.search(new RegExp(obL[i].replace(/[^a-zA-Z0-9]/g,chcrp)+"\\s*\\=\\s*\\x7b"));i++;}
- var s2=s1.substr(ind+obL[i-1].length+1); s2=s2.substr(s2.indexOf("{")); s2=s2.substr(0,s2.indexOf("<\/script>"));
- i=0;
- while((!obj1)&&i<500){try{ obj1=JSON.parse(s2); }catch(e){ s2=s2.substr(0,s2.lastIndexOf(";")); i++; }}
- return obj1;
- },
- "gran":function(ra){ //parse a ".runs" array
- var so=document.createElement("span"),t,e,a,b,i=ra.length;ra.reverse();while(i--){t=ra[i].text;if(a=ra[i].navigationEndpoint){e=document.createElement("a");e.textContent=t;if(b=a.urlEndpoint)e.href=YTVG.urlqp(b.url).q;else if(b=a.browseEndpoint)e.href="#chnl:"+b.browseId;else if(b=a.searchEndpoint)e.href="#q="+b.query.substr(1);}else e=document.createTextNode(t); so.appendChild(e);so.appendChild(document.createElement("br"));}
- return so;
- },
- "gvid":function gvid(id,cb,stp){
- if(!id)return 0;
- if(typeof cb!="function")cb=console.log;
- var rdr=0, ytu=YTVG.yt+"/watch?v="+id, xhr1=new XMLHttpRequest();
- if(!stp){
- YTVG.haz(ytu,function(b){
- gvid(id,cb,b?"rdy":"dsv");
- }); return 0;
- }
- var atLaast=function(){
- var s1=xhr1.responseText,
- vob=(YTVG.vids[id]={"raw":s1}),obj1=YTVG.gJSON(s1,"ytInitialPlayerConfig,ytplayer.config"),obj2=YTVG.gJSON(s1,'["ytInitialData"]'),obj3=YTVG.gJSON(s1,'["ytInitialPlayerResponse"]');
- //if(!obj1){cb({"Error":"no config object"});return 0;}
- if(obj1){ if(YTVG.basej!=obj1.assets.js){YTVG.basej=obj1.assets.js;delete YTVG.sig_par;}
- Object.assign(vob,obj1); }
- if(obj2)Object.assign(vob,obj2);
- if(obj3)Object.assign(vob,obj3);
- /*
- sometimes these url encoded comma separated values:
- obj1.args.url_encoded_fmt_stream_map;
- &
- obj1.args.adaptive_fmts;
- */
- var a,b,c,h,pr1=(obj1.args.player_response=JSON.parse(obj1.args.player_response)),f=pr1.streamingData.formats;
- //always this JSON value: pr1.streamingData.formats[0];
- /* these should have same data although encoded differently
- pr1.streamingData.adaptiveFormats
- obj1.args.adaptive_fmts
- whady know, these are same too
- pr1.streamingData.formats
- obj1.args.url_encoded_fmt_stream_map
- window["ytInitialData"]
- comments object:
- ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[2].itemSectionRenderer
- //title:
- ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text
- obj1.args.player_response.videoDetails.title
- //description:
- ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs
- obj1.args.player_response.videoDetails.shortDescription
- */
- if((c=f[0])[h="cipher"]||c[h="signatureCipher"]){
- var done=function(){var i=f.length,af;
- while(i--){b=YTVG.urlqp((c=f[i])[h]);c.url=b.url+"&"+b.sp+"="+YTVG.sig_par(b.s);}
- if(af=pr1.streamingData.adaptiveFormats){i=af.length;while(i--){b=YTVG.urlqp((c=af[i])[h]);c.url=b.url+"&"+b.sp+"="+YTVG.sig_par(b.s);}}
- cb(vob);};
- if(YTVG.sig_par)done();else YTVG.cphrgt(done);
- }else cb(vob);
- };
- if(stp=="dsv"){ xhr1.open("GET",YTVG.cu2+ytu,!0);
- xhr1.onload=function(){ xhr1.open("GET",xhr1.getResponseHeader("content-location")); xhr1.onload=atLaast; xhr1.send(); };
- }else{
- xhr1.open("GET",YTVG.cu1+ytu,!0);
- xhr1.onload=atLaast;
- }
- xhr1.send();
- }
- };
- //["ytInitialData"] = {
- </script>
- Enter url or id: <input id="id"> <button id="gob">GO</button> <button id="stp">STOP</button><br>
- Title: <span id="ti1"></span><br>
- <video id="v1" controls playsinline webkit-playsinline></video><br>
- <div id="dsc"></div>
- <br>Related Videos:<br><br>
- <div id="nxt"></div>
- <script type="text/javascript">
- var d=document,cE="createElement",aC="appendChild",gE="getElementById",
- _id=d[gE]("id"),gob=d[gE]("gob"),stp=d[gE]("stp"),v1=d[gE]("v1"),ti1=d[gE]("ti1"),dsc=d[gE]("dsc"),nxt=d[gE]("nxt"),
- errs=0,
- ge_it=function(uL,eL,vid){
- YTVG.haz(uL,function(b,u,s){
- if(b) eL.src=YTVG.cu1+uL; else{ errs++; if(errs>3){ console.error("Too many media errors"); return 0;}
- var xhr5=new XMLHttpRequest();
- xhr5.open("GET",YTVG.cu2+uL);
- xhr5.onload=function(){
- if(xhr5.status<300){
- eL.src=YTVG.cu1+uL;
- }else{ var NO=YTVG.yt+"/watch?v="+vid; YTVG.noHaz.push(NO);
- YTVG.gvid(vid,Svid); setTimeout(function(){ YTVG.noHaz.splice(YTVG.noHaz.indexOf(NO),1); },7000);
- }
- };
- xhr5.send();
- }
- });
- },
- Svid=function(vob){var a,c,f,b=vob.args.player_response.streamingData,csrc,own,fmt=(vob.vsrc=b.formats.concat(b.adaptiveFormats||[])),nvds,i;
- v1.cv=vob;
- if(self.MediaSource&&self.MediaSource.isTypeSupported){
- var i2=fmt.length,supt=[],tv,pv,pa;
- vob.supt=supt;
- while(i2--){
- if(self.MediaSource.isTypeSupported((tv=fmt[i2]).mimeType)){ supt.push(tv); if(tv.audioQuality&&tv.fps)csrc=tv.url; }
- }
- if((!csrc)&&(i2=supt.length)){
- while(i2--){ vs=supt[i2];
- if(MediaSource.isTypeSupported(vs.mimeType)){
- if(vs.height&&vs.height<600&&((!pv)||pv.height<vs.height)){ pv=vs; }
- if(vs.audioQuality&&((!pa)||vs.audioQuality.indexOf("MEDIUM")>0)){ pa=vs; }
- }
- }
- csrc=pv.url;
- if(!self.au_b){ self.au_b=new Audio(); au_b.controls=!0; v1.controls=!1;
- v1.onload=function(){ au_b.style.width=v1.clientWidth+"px"; };
- d.body.insertBefore(au_b,dsc);
- }
- ge_it(pa.url,au_b,vob.args.player_response.videoDetails.videoId);
- au_b.onseek=function(){ v1.currentTime=au_b.currentTime; };
- au_b.onplay=function(){ au_b.onseek(); v1.play(); };
- au_b.onpause=function(){ v1.pause(); };
- } // else alert("Can't play video");
- }
- if(!csrc)csrc=fmt[0].url;
- ge_it(csrc,v1,vob.args.player_response.videoDetails.videoId);
- document.title="YTVP: "+(ti1.innerText=(a=vob.args.player_response.videoDetails).title);
- dsc.innerHTML="Posted by: <a href='#chnl:"+a.channelId+"'>"+a.author+"</a><br>"+a.shortDescription.replace(/\n/g,"<br>");
- if(vob.webWatchNextResponseExtensionData){
- nvds=vob.webWatchNextResponseExtensionData.relatedVideoArgs.split(",").map(YTVG.urlqp);
- nxt.innerHTML="";i=0;
- while(i<nvds.length){a=d[cE]("a");a.href="#v="+(c=nvds[i]).id;b=d[cE]("img");b.src=_scrm("httpsc^^web;@r:hive;org^web^httpsc^^i;ytimg;:om^vi^")+c.id+"/mqdefault.jpg";a[aC](b);a[aC](d[cE]("br"));a[aC](d.createTextNode(c.aria_label));nxt[aC](a);i++;}
- }
- },
- Lvid=(gob.onclick=function(){if(_id.value){var id,id1=_id.value,uo,a,b;
- if(id1.indexOf("?")>0){ uo=YTVG.urlqp(id1); if(uo.v)id=uo.v; }
- if((!id)&&(a=id1.indexOf("/embed/"))>0)id=id1.substr(a+7);
- if(!id)id=id1;
- if(id){ if((a=id.indexOf("?"))>0)id=id.substr(0,a);
- if((b=YTVG.vids[id])&&(YTVG.urlqp(b.args.player_response.streamingData.formats[0].url).expire*1000) > (new Date()).getTime())Svid(b);
- else YTVG.gvid(id,Svid);
- }
- }});
- _id.onkeydown=function(e){if(e.keyCode==13)Lvid();};
- /*
- v1.onerror=function(){ if(v1.getAttribute("src")&&isNaN(v1.duration)){v1.fi=v1.fi||0;
- if(v1.cv&&v1.fi<v1.cv.vsrc.length)v1.src=v1.cv.vsrc[++v1.fi].url;
- }};
- */
- stp.onclick=function(){v1.src="";v1.cv=!1;document.title="YTVP";ti1.innerHTML="";dsc.innerHTML="";nxt.innerHTML="";};
- </script>
- </body></html>
Add Comment
Please, Sign In to add comment