Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YouTube downloader
- // @namespace http://concentratedentropy.wordpress.com/
- // @version 2
- // @description Download YouTube videos via an interface that should hopefully get better
- // @include http://*.youtube.com/watch?v=*
- // ==/UserScript==
- //old version: http://pastebin.com/Y7qaqju9 (which shares practically no code other than the above metadata)
- //do also note that using the links created by this script may violate YouTube's terms of service, specifically, from section 4.C:
- //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.
- function p(f)
- {
- return ({
- 5:'240p/lq/mp3',
- 18:'360p/mq/aac',
- 34:'360p/hq/aac',
- 35:'480p/hq/aac',
- 22:'720p/hq/aac',
- 37:'1080p/hq/aac',
- 38:'4k/hq/aac',
- 43:'360p/mq/vorbis',
- 44:'480p/mq/vorbis',
- 45:'720p/mq/vorbis'
- }[f]||f);
- //legend: hq ~ barely acceptable, mq ~ kind of shitty, lq ~ why.tiff
- }
- var xhr=new XMLHttpRequest;
- xhr.onreadystatechange=function(){
- if(this.readyState!=4||this.responseText=='')return;
- var t=this.responseText.split('&');
- for(var i=0;i<t.length;i++)if(t[i].substring(0,3)=='url')break;
- if(i==t.length)return;
- var a=document.getElementById('watch-description-extras');
- var b=document.createElement('h4');
- b.textContent='Download:';
- var c=document.createElement('ul');
- 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('');
- a.appendChild(b);
- a.appendChild(c);
- };
- xhr.open('GET','http://www.youtube.com/get_video_info?video_id='+location.href.split('v=')[1].substring(0,11),true);
- xhr.send();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement