Audio/video stream recording forums
|
Attention Visitor: |
You may have to register or log in before you can post:
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
Downloading YouTube videos with JavaScriptI used the following javascript for downloading youtube videos:
Code:
javascript:window.open('http://youtube.com/get_video?video_id='+window.location.href.split('?')[1].match(/v=([^(&|$)]*)/)[1]+'&t='+document.getElementById('movie_player').src.match(/t=([^(&|$)]*)/)[1]); |
#2
|
|||
|
|||
Re: Downloading YouTube videos with JavaScriptTry the following bookmarklet
Code:
javascript:(function(){if(document.getElementById('download-youtube-video'))return;var%20args=null,video_title=null,video_id=null,video_hash=null;var%20download_code=new%20Array();var%20fmt_labels={'18':'standard%20MP4','22':'HD%20720p','37':'HD%201080p'};try{args=yt.getConfig('SWF_ARGS');video_title=yt.getConfig('VIDEO_TITLE')}catch(e){}if(args){var%20fmt_url_map=unescape(args['fmt_url_map']);if(fmt_url_map=='')return;video_id=args['video_id'];video_hash=args['t'];video_title=video_title.replace(/[%22\'\?\\\/\:\*%3C%3E]/g,'');var%20fmt=new%20Array();var%20formats=fmt_url_map.split(',');var%20format;for(var%20i=0;i%3Cformats.length;i++){var%20format_elems=formats[i].split('|');fmt[format_elems[0]]=unescape(format_elems[1])}for(format%20in%20fmt_labels){if(fmt[format]!=null){download_code.push('%3Ca%20href=\''+(fmt[format]+'&title='+video_title)+'\'%3E'+fmt_labels[format]+'%3C/a%3E')}else%20if(format=='18'){download_code.push('%3Ca%20href=\'http://www.youtube.com/get_video?fmt=18&video_id='+video_id+'&t='+video_hash+'\'%3E'+fmt_labels[format]+'%3C/a%3E')}}}if(video_id==null||video_hash==null)return;var%20div_embed=document.getElementById('watch-embed-div');if(div_embed){var%20div_download=document.createElement('div');div_download.innerHTML='%3Cbr%20/%3E%3Cspan%20id=\'download-youtube-video\'%3EDownload:%20'+download_code.join('%20|%20')+'%3C/span%3E';div_embed.appendChild(div_download)}})();void(0) |
#3
|
|||
|
|||
Re: Downloading YouTube videos with JavaScriptThe following bookmarklet works for me in Google Chrome:
Code:
javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + yt.getConfig("SWF_ARGS")['video_id'] + "&sk=" + yt.getConfig("SWF_ARGS")['sk'] + '&t=' + yt.getConfig("SWF_ARGS")['t']; |
#4
|
|||
|
|||
Re: Downloading YouTube videos with JavaScriptAnd here is another working bookmarklet
Code:
javascript:var fmt=35;var success=0;var fmt_url_map = unescape(yt.getConfig("SWF_ARGS")['fmt_url_map']);var fmt_url_a = fmt_url_map.split(',');for(idx in fmt_url_a){fmt_url_a[idx]=fmt_url_a[idx].split('|');if(fmt_url_a[idx][0]==fmt){window.location.assign(fmt_url_a[idx][1]);success=1;break;}}if(success==0){var err_msg = "Video available in these formats:\n";for(idx in fmt_url_a){switch(fmt_url_a[idx][0]){case '5':err_msg+=".flv FLV1-320x240 MP3-22k-mono fmt=5\n";break;case '18':err_msg+=".mp4 H264-480x360 AAC-44k-st fmt=18\n";break;case '22':err_msg+=".mp4 H264-1280x720 AAC-44k-st fmt=22\n";break;case '34':err_msg+=".flv H264-320x240 AAC-22k-st fmt=34\n";break;case '35':err_msg+=".flv H264-480x368 AAC-44k-st fmt=35\n";break;case '37':err_msg+=".mp4 H264-1920x1080 AAC-44k-st fmt=37\n";break;default:err_msg+="unknown format fmt="+fmt_url_a[idx][0]+"\n";};};alert(err_msg);}; The highest quality version is usually first in the list so the following bookmarklet will download the highest quality video file: Code:
javascript:var fmt_url_map = unescape(yt.getConfig("SWF_ARGS")['fmt_url_map']);if(fmt_url_map.indexOf(',') != -1){window.location.assign(fmt_url_map.substring(fmt_url_map.indexOf('|')+1, fmt_url_map.indexOf(',')))}else window.location.assign(fmt_url_map.substring(fmt_url_map.indexOf('|')+1)); |
Tags: bookmarklet, bookmarklets, download, javascript, youtube |
Thread Tools | |
Display Modes | |
|
|