Advertisement
0x3c0

Untitled

Aug 17th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           YouTube downloader
  3. // @namespace      http://concentratedentropy.wordpress.com/
  4. // @version        2
  5. // @description    Download YouTube videos via an interface that should hopefully get better
  6. // @include        http://*.youtube.com/watch?v=*
  7. // ==/UserScript==
  8.  
  9. //old version: http://pastebin.com/Y7qaqju9 (which shares practically no code other than the above metadata)
  10. //do also note that using the links created by this script may violate YouTube's terms of service, specifically, from section 4.C:
  11. //You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.
  12.  
  13. function p(f)
  14. {
  15. return ({
  16. 5:'240p/lq/mp3',
  17. 18:'360p/mq/aac',
  18. 34:'360p/hq/aac',
  19. 35:'480p/hq/aac',
  20. 22:'720p/hq/aac',
  21. 37:'1080p/hq/aac',
  22. 38:'4k/hq/aac',
  23. 43:'360p/mq/vorbis',
  24. 44:'480p/mq/vorbis',
  25. 45:'720p/mq/vorbis'
  26. }[f]||f);
  27. //legend: hq ~ barely acceptable, mq ~ kind of shitty, lq ~ why.tiff
  28. }
  29. var xhr=new XMLHttpRequest;
  30. xhr.onreadystatechange=function(){
  31. if(this.readyState!=4||this.responseText=='')return;
  32. var t=this.responseText.split('&');
  33. for(var i=0;i<t.length;i++)if(t[i].substring(0,3)=='url')break;
  34. if(i==t.length)return;
  35. var a=document.getElementById('watch-description-extras');
  36. var b=document.createElement('h4');
  37. b.textContent='Download:';
  38. var c=document.createElement('ul');
  39. c.innerHTML=unescape(t[i].split('=')[1]).split(',').map(function(y){return '<li style="display:inline;margin-right:0.5em"><a href="'+unescape(y.substring(4))+'">'+p(y.substr(y.lastIndexOf('=')+1))+'</a></li>';}).join('');
  40. a.appendChild(b);
  41. a.appendChild(c);
  42. };
  43. xhr.open('GET','http://www.youtube.com/get_video_info?video_id='+location.href.split('v=')[1].substring(0,11),true);
  44. xhr.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement