Publishing System Settings Logout Login Register
Make the Easiest Trick to Download YouTube Video using JavaScript
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on September 2nd, 2009
8367 views
JavaScript
Since YouTube refuse to offer such a basic video download tool or similar functionality through its own site, lots of methods are still available for all the YouTube fans. From online application to desktop software, all YouTube tricks are based a simple mechanism of YouTube video servers. That is, just get out of that real playing video URL address from embedded YouTube Flash player on page using its own algorithm. As it is, now we know that algorithm, and we can make the world's easiest trick using JavaScript to download the same YouTube video like other methods do.

Okay, so this simple tutorial is going to show you how to make such a JavaScript segment to trick YouTube.

To start off, lets see the basic JavaScript code for normal YouTube videos:

javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id'] + "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&t=' + swfArgs['t'];


The main syntax "window.location.href" of this JavaScript, is the beginner's client-side object "location" with its property "href" to access the "location" property of the "window" object. The result of this behavior is opening a window in specified URL upon current page.

Client-Side JavaScript Reference: http://docs.sun.com/source/816-6408-10/location.htm

The parameter part of "http://youtube.com/get_video?" is the syntax of requesting the video from YouTube's depository server.

We know, those major arguments of requesting specified video on server, such as "video_id", "l", "sk" and "t", are written as ActionScript inside YouTube's Flash player. So we can retrieve the arguments out of the Flash object, by the same parameter "swfArgs['*']". And all parameters after the question mark are clear: video_id=' + swfArgs['video_id'] + "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&t=' + swfArgs['t']

Now just type or paste the exact client-side JavaScript in the address bar of the browser and enter to go, after the YouTube video page is completely loaded. A new window will prompt to ask you to download a file called "video.flv", that's the YouTube video file requested.

And the derivatives of this JavaScript trick are for the latest YouTube HQ (High Quality) and HD (High Definition) videos. The only thing we should know is the new argument. It's "fmt" to differentiate among normal quality, HQ quality and HD quality if available. And the "fmt" value for HQ is "18", as HD is "22". Then we can add the argument with specified value to retrieve different files from the server.

JavaScript for HQ (High Quality) YouTube video if it is available:
javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id'] + "&fmt=18" + "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&t=' + swfArgs['t']; 


JavaScript for HD (High Definition) YouTube video if it is available:
javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id'] + "&fmt=22" + "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&t=' + swfArgs['t'];


Again just type or paste the script in address bar and go.

Someone asks, this trick is so easy to learn and try, but why some YouTube video download tools still survive? Because this trick is only for YouTube, the world's largest video sharing center, and other video sharing sites need different tricks to go. Certainly you can make another easiest JavaScript trick for them. However, most common users will like such a full-featured program like Video Downloader to work with most other video sites, and even convert videos for iPod or DVD ready.

Well, that's the tutorial, hopefully now you're able to make your own way to enjoy. You'll like JavaScript more than ever. And this trick works as long as you want until YouTube changes its own algorithm. No software, no third party sites, only a small piece of JavaScript when you're browsing YouTube, the magic is definitely the world's easiest YouTube video trick, isn't it?
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send


This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top