IWBH_01

YTVP_archive_too

Aug 18th, 2020 (edited)
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 10.06 KB | None | 0 0
  1. <!Doctype html><html><head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <title>YTVP</title>
  4. <style>
  5. #nxt a{
  6. margin: 10px;
  7. width: 200px;
  8. position: relative;
  9. padding: 10px;
  10. border: 2px solid blue;
  11. display: inline-block;
  12.  
  13. }
  14.  
  15. #nxt a img{
  16. width: 200px;
  17. }
  18.  
  19. #v1{
  20. max-width: 99%;
  21. }
  22.  
  23. </style>
  24. </head><body>
  25. <script type="text/javascript" id="ytvg_archive_mod.js">
  26.  
  27. /*
  28. 2020-Aug-19
  29.  
  30. YouTube video get (archive.org mod)
  31. archive youtube videos and watch them too
  32.  
  33. ytInitialPlayerConfig.args.player_response
  34. or
  35. ytplayer.config.args.player_response
  36. */
  37.  
  38.  
  39. if(!Object.assign){
  40. Object.assign=function assign(oo,o2){
  41. for(var p in o2)oo[p]=o2[p];
  42. };
  43. }
  44.  
  45. var chcrp=function(s){return "\\x"+s.charCodeAt(0).toString(16);},
  46. __vids_;
  47. if(self.YTVG&&Object.keys(self.YTVG.vids).length)__vids_=self.YTVG.vids;
  48.  
  49. var _kyp=["@","a",":","c","/","^",".",";"],
  50.  
  51. _scrm=function(s){
  52.  var a=s.split(""),i=0,L=a.length,p;
  53.  while(i<L){
  54.  p=_kyp.indexOf(a[i]);
  55.  if(p>=0){a[i]=_kyp[p&1?p-1:p+1];}
  56.   i++;
  57.  }
  58.  return a.join("");
  59. };
  60.  
  61. self.$B=self.$B||{};
  62. self.YTVG={
  63.  "vids":__vids_||{},
  64.  "cu1":_scrm(($B.ac="httpsc^^web;@r:hive;org^")+"web^"),
  65.  "cu2":_scrm($B.ac+"s@ve^"),
  66.  "yt":_scrm("httpsc^^www;youtube;:om"),
  67.  "squ":_scrm("httpsc^^web;@r:hive;org^:dx^se@r:h^:dx?limit=50&output=json&limit=50&url="),
  68.  
  69. "noHaz":[],
  70.  
  71. "haz":function isArchived(adr,cb){
  72.   if(YTVG.noHaz.indexOf(adr)>=0){cb(!1,adr);return 0;}
  73.    var adr2=(adr.substr(0,6)=="https:")?("http"+adr.substr(5)):adr,
  74.    xhr3=new XMLHttpRequest();
  75.    xhr3.open("GET",YTVG.squ+encodeURIComponent(adr));
  76.    xhr3.onload=function(){  var R=JSON.parse(xhr3.response); if(!R.length){ cb(!1,adr,4); return 0;}
  77.     var sc=R[0].indexOf("statuscode"),L=R.length,i=L;
  78.      
  79.      while((i--)>1){
  80.       if((R[i][sc]*1)<400){ cb(!0,adr,R[i]);  i=-2; }
  81.    
  82.     }
  83.     if(i>-1) cb(!1,adr,4);
  84.    };
  85.    xhr3.send();
  86.   },
  87.  
  88.  "urlqp":function URLquerryParse(q,I){ if(I=(q.indexOf("?")+1))q=q.substr(I);
  89.   var ubj={},a=q.split("&"),i=a.length,s,ei;
  90.   while(i--){ei=(s=a[i]).indexOf('='); ubj[s.substr(0,ei)]=decodeURIComponent(s.substr(ei+1).replace(/\+/g," ")); }
  91.   return ubj;
  92.  },
  93.  
  94.  
  95.  "cphrgt":function cphrgt(cb){
  96.    var T=this,jsu=T.yt+T.basej,ongot=function(s){
  97.     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("")',
  98.     cf=s.substr(cfi+fi.length,1000),cfo=cf.substr(0,cf.indexOf("."))+"={",
  99.     cfos=s.substr(s.indexOf(cfo),1000);
  100.     eval(T.sig_enc_obj=cfos.substr(0,cfos.indexOf("}};")+3));
  101.     eval("var _cf__"+fi+cf.substr(0,cf.indexOf(fe)+fe.length)+";};");
  102.  
  103.     T.sig_par=_cf__;
  104.     if(typeof cb=="function")cb();
  105.    
  106.   };
  107.   T.haz(jsu,function(b){
  108.    var xhr2=new XMLHttpRequest();
  109.     xhr2.open("GET",(b?T.cu1:T.cu2)+jsu);
  110.     xhr2.onload=function(){ ongot(xhr2.response); };
  111.     xhr2.send();
  112.   });
  113.  
  114.  },
  115.  
  116.  "gJSON":function(s1,pnm){
  117.   var obL=pnm.split(","),ind=-1,i=0,obj1;
  118.  
  119.   while(ind<0&&i<obL.length){ind=s1.search(new RegExp(obL[i].replace(/[^a-zA-Z0-9]/g,chcrp)+"\\s*\\=\\s*\\x7b"));i++;}
  120.  var s2=s1.substr(ind+obL[i-1].length+1); s2=s2.substr(s2.indexOf("{")); s2=s2.substr(0,s2.indexOf("<\/script>"));
  121.   i=0;
  122.   while((!obj1)&&i<500){try{ obj1=JSON.parse(s2); }catch(e){ s2=s2.substr(0,s2.lastIndexOf(";")); i++; }}
  123.   return obj1;
  124.  },
  125.  "gran":function(ra){  //parse a ".runs" array
  126.   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"));}
  127.   return so;
  128.  },
  129.  
  130.  "gvid":function gvid(id,cb,stp){
  131.   if(!id)return 0;
  132.   if(typeof cb!="function")cb=console.log;
  133.   var rdr=0, ytu=YTVG.yt+"/watch?v="+id, xhr1=new XMLHttpRequest();
  134.   if(!stp){
  135.    YTVG.haz(ytu,function(b){
  136.     gvid(id,cb,b?"rdy":"dsv");
  137.    }); return 0;
  138.   }
  139.  
  140.  
  141.   var atLaast=function(){
  142.    var s1=xhr1.responseText,
  143.    vob=(YTVG.vids[id]={"raw":s1}),obj1=YTVG.gJSON(s1,"ytInitialPlayerConfig,ytplayer.config"),obj2=YTVG.gJSON(s1,'["ytInitialData"]'),obj3=YTVG.gJSON(s1,'["ytInitialPlayerResponse"]');
  144.    //if(!obj1){cb({"Error":"no config object"});return 0;}
  145.    if(obj1){ if(YTVG.basej!=obj1.assets.js){YTVG.basej=obj1.assets.js;delete YTVG.sig_par;}
  146.    Object.assign(vob,obj1); }
  147.    if(obj2)Object.assign(vob,obj2);
  148.    if(obj3)Object.assign(vob,obj3);
  149.  
  150. /*
  151. sometimes these url encoded comma separated values:
  152. obj1.args.url_encoded_fmt_stream_map;
  153. &
  154. obj1.args.adaptive_fmts;
  155. */
  156.  
  157. var a,b,c,h,pr1=(obj1.args.player_response=JSON.parse(obj1.args.player_response)),f=pr1.streamingData.formats;
  158.  
  159. //always this JSON value:     pr1.streamingData.formats[0];
  160.  
  161. /* these should have same data although encoded differently
  162. pr1.streamingData.adaptiveFormats
  163. obj1.args.adaptive_fmts
  164.  
  165. whady know, these are same too
  166. pr1.streamingData.formats
  167. obj1.args.url_encoded_fmt_stream_map
  168.  
  169.  
  170.  
  171.  
  172. window["ytInitialData"]
  173.  
  174. comments object:
  175. ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[2].itemSectionRenderer
  176.  
  177.  
  178.  
  179. //title:
  180. ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text
  181. obj1.args.player_response.videoDetails.title
  182.  
  183.  
  184. //description:
  185. ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs
  186. obj1.args.player_response.videoDetails.shortDescription
  187. */
  188.  
  189.  
  190. if((c=f[0])[h="cipher"]||c[h="signatureCipher"]){
  191.  var done=function(){var i=f.length,af;
  192.      while(i--){b=YTVG.urlqp((c=f[i])[h]);c.url=b.url+"&"+b.sp+"="+YTVG.sig_par(b.s);}
  193.      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);}}
  194.      cb(vob);};
  195.  if(YTVG.sig_par)done();else YTVG.cphrgt(done);
  196.    }else cb(vob);
  197.   };
  198.  
  199.  
  200.   if(stp=="dsv"){ xhr1.open("GET",YTVG.cu2+ytu,!0);
  201.    xhr1.onload=function(){ xhr1.open("GET",xhr1.getResponseHeader("content-location")); xhr1.onload=atLaast;  xhr1.send(); };
  202.   }else{
  203.    xhr1.open("GET",YTVG.cu1+ytu,!0);
  204.    xhr1.onload=atLaast;
  205.   }
  206.   xhr1.send();
  207.  }
  208. };
  209.  
  210. //["ytInitialData"] = {
  211.  
  212.  
  213.  
  214. </script>
  215. Enter url or id: <input id="id"> <button id="gob">GO</button> <button id="stp">STOP</button><br>
  216. Title: <span id="ti1"></span><br>
  217. <video id="v1" controls playsinline webkit-playsinline></video><br>
  218. <div id="dsc"></div>
  219. <br>Related Videos:<br><br>
  220. <div id="nxt"></div>
  221. <script type="text/javascript">
  222. var d=document,cE="createElement",aC="appendChild",gE="getElementById",
  223. _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"),
  224. errs=0,
  225. ge_it=function(uL,eL,vid){
  226.  YTVG.haz(uL,function(b,u,s){
  227.   if(b) eL.src=YTVG.cu1+uL; else{ errs++; if(errs>3){ console.error("Too many media errors"); return 0;}
  228.    var xhr5=new XMLHttpRequest();
  229.    xhr5.open("GET",YTVG.cu2+uL);
  230.    xhr5.onload=function(){
  231.     if(xhr5.status<300){
  232.     eL.src=YTVG.cu1+uL;
  233.    }else{ var NO=YTVG.yt+"/watch?v="+vid; YTVG.noHaz.push(NO);
  234.     YTVG.gvid(vid,Svid); setTimeout(function(){ YTVG.noHaz.splice(YTVG.noHaz.indexOf(NO),1); },7000);
  235.    }
  236.   };
  237.   xhr5.send();
  238.  }
  239. });
  240. },
  241.  
  242. 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;
  243. v1.cv=vob;
  244. if(self.MediaSource&&self.MediaSource.isTypeSupported){
  245.  var i2=fmt.length,supt=[],tv,pv,pa;
  246.  vob.supt=supt;
  247.  while(i2--){
  248.   if(self.MediaSource.isTypeSupported((tv=fmt[i2]).mimeType)){ supt.push(tv); if(tv.audioQuality&&tv.fps)csrc=tv.url; }
  249.  }
  250.  if((!csrc)&&(i2=supt.length)){
  251.    
  252.  
  253.    while(i2--){ vs=supt[i2];
  254.      if(MediaSource.isTypeSupported(vs.mimeType)){
  255.        if(vs.height&&vs.height<600&&((!pv)||pv.height<vs.height)){ pv=vs; }
  256.        if(vs.audioQuality&&((!pa)||vs.audioQuality.indexOf("MEDIUM")>0)){ pa=vs; }
  257.       }
  258.     }
  259.  
  260.  
  261.  
  262.     csrc=pv.url;
  263.     if(!self.au_b){ self.au_b=new Audio(); au_b.controls=!0; v1.controls=!1;
  264.      v1.onload=function(){ au_b.style.width=v1.clientWidth+"px"; };
  265.      d.body.insertBefore(au_b,dsc);
  266.     }
  267.     ge_it(pa.url,au_b,vob.args.player_response.videoDetails.videoId);
  268.     au_b.onseek=function(){ v1.currentTime=au_b.currentTime; };
  269.     au_b.onplay=function(){ au_b.onseek(); v1.play(); };
  270.     au_b.onpause=function(){ v1.pause(); };
  271.   } // else alert("Can't play video");
  272.  }
  273.  if(!csrc)csrc=fmt[0].url;
  274.  ge_it(csrc,v1,vob.args.player_response.videoDetails.videoId);
  275.  document.title="YTVP: "+(ti1.innerText=(a=vob.args.player_response.videoDetails).title);
  276.  dsc.innerHTML="Posted by: <a href='#chnl:"+a.channelId+"'>"+a.author+"</a><br>"+a.shortDescription.replace(/\n/g,"<br>");
  277.  
  278.   if(vob.webWatchNextResponseExtensionData){
  279.    nvds=vob.webWatchNextResponseExtensionData.relatedVideoArgs.split(",").map(YTVG.urlqp);
  280.    nxt.innerHTML="";i=0;
  281.    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++;}
  282.  }
  283.  
  284. },
  285.  
  286. Lvid=(gob.onclick=function(){if(_id.value){var id,id1=_id.value,uo,a,b;
  287. if(id1.indexOf("?")>0){ uo=YTVG.urlqp(id1); if(uo.v)id=uo.v; }
  288.  if((!id)&&(a=id1.indexOf("/embed/"))>0)id=id1.substr(a+7);
  289.  if(!id)id=id1;
  290.  if(id){ if((a=id.indexOf("?"))>0)id=id.substr(0,a);
  291.  
  292.   if((b=YTVG.vids[id])&&(YTVG.urlqp(b.args.player_response.streamingData.formats[0].url).expire*1000) > (new Date()).getTime())Svid(b);
  293.   else YTVG.gvid(id,Svid);
  294.  
  295.  }
  296. }});
  297.  
  298. _id.onkeydown=function(e){if(e.keyCode==13)Lvid();};
  299.  
  300. /*
  301. v1.onerror=function(){ if(v1.getAttribute("src")&&isNaN(v1.duration)){v1.fi=v1.fi||0;
  302.  if(v1.cv&&v1.fi<v1.cv.vsrc.length)v1.src=v1.cv.vsrc[++v1.fi].url;
  303. }};
  304. */
  305.  
  306. stp.onclick=function(){v1.src="";v1.cv=!1;document.title="YTVP";ti1.innerHTML="";dsc.innerHTML="";nxt.innerHTML="";};
  307. </script>
  308. </body></html>
Add Comment
Please, Sign In to add comment