Saturday, September 6, 2008

How to download Youtube Videos using Javascript?

You can use Javascript and AJAX technologies to download Youtube videos on your web page that is all client based solution. I have outlined the steps to extract the values needed to form the URL to download the Youtube videos.

First we should know Youtube download URL summary:
Youtube videos can be downloaded from the URL http://youtube.com/get_video.php?=&l=&t=&sk=&fs=1. All we need are the values of video_id, l , t, and sk. My script extracts these values from Youtube's HTML page.

The summary of the script:
Download the source of the page of the URL http://in.youtube.com/watch?v=VDAGIFjt6m4
(
VDAGIFjt6m4 is the ID of a video). Look for a particular pattern in the source. Once the pattern is extracted convert it into JSON format. From the JSON data walk through and get the values of id, l, t, and sk.

More detailed algorithm.
1) Get the page source from Youtube using the public URL - http://in.youtube.com/watch?v=VDAGIFjt6m4
In the example VDAGIFjt6m4 is the ID. The ID can change depending upon your video.

2) The source will be entire page which has the Youtube video embedded we are only interested in the following HTML -
var swfArgs = {"BASE_YT_URL": "http://in.youtube.com/", "vq": null, "sourceid": "y", "video_id": "VDAGIFjt6m4", "l": 65, "sk": "mkKFIRWXheJgUGsaU6Bx2LsnWvZldVraC", "fmt_map": "6/720000/7/0/0", "t": "OEgsToPDskK0DEe01pPPKzJJ700ykmac", "hl": "en", "plid": "AARWNMbnD8zgFCZ0AAAAoAAYAAA", "sdetail": "p%3A/"};

3) Extract the interested line using the following Regular Expression "swfArgs(\\s*)=(\\s*)\\{(.*)\\}"

var ytPattern = "swfArgs(\\s*)=(\\s*)\\{(.*)\\}";
var re = new RegExp(ytPattern);
var matchVar = eval('({' + re.exec(strDoc) + '})');
Now from matchVar get the values like matchVar['video_id'] or matchVar['sk']

Once you the values substitute in
http://youtube.com/get_video.php?video_id=&l=&t=&sk=&fs=1

Disclaimer: If Youtube changes its page this script will not work. This is working as of Sept 6 2008.

Friday, August 22, 2008

New Gadget - News Flipper


News Flipper is a picture based news reader. You can flip the news like album covers. The user interface is based on Image Flow script. It has been modified to show the news articles. etc. It is developed as a Google gadget so that you can add this in your web page also.

To add it on your web page you can do one of the following
1) Go to Google Gadget's preview OR Add Gadget page.
2) Add to Google

3) Use the following script on your webpage-

Thursday, August 14, 2008

Movie trailers web page updated.

The movie trailers and Youtube mashup is gaining some traction in last few weeks. I have update the web page. I have also explained how the mash up works. Leave your suggestions and comemnts.

Saturday, August 9, 2008

Youtube Player shows "Olympics 2008"

It is very easy to change the initial search keyword in the Youtube Player. You can do this by changing the value of up_searchkey parameter in the script. I have recently changed that value to "Olympics 2008".
It is also possible to supply your own initial video. Check this. I will update about it later.

Check out some related links.
http://olympicsresults.blogspot.com
http://indiantrailers.blogspot.com

Thursday, June 26, 2008

Movie trailer gadget

I am planning to extend the feature set of the Movie Trailers gadget. Let me know what would you like to see in the gadget. Your suggestion and feedback will drive the next release. Also check the Youtube Player gadget.

Monday, December 10, 2007

Simple and elegant way to watch movie trailers.

MovieTube does a smart search on the Youtube videos and displays the trailers and clips of latest upcoming movies. Add this movietube player on your webpage.

Sunday, December 9, 2007

Download feature is back

Finally I got some time to fix the download feature in the youtube player. Now you can download the videos you like. The videos are downloaded in the FLV format.
All you have to do is to click button.

FLV can be played in lot of player available on PC and MAC.
I like VLC -

Monday, August 27, 2007

You can now search videos from a particular user.

Youtube player has been enchanced to include search based on the usernames. This feature was requested by lot of users and visitors. I hope you will find this useful.
PS: The download feature is taken out until I find a way to extract the right ID from youtube pages.

Sunday, May 13, 2007

Download and customize Youtube (3 simple steps)

Now you can download Youtube Videos and customize the search string.

1. Go to the Google gadget page
2. Enter your own search string
3. Click "Get the code" and paste the code on youe webpage.

To do download you have to click on the Youtube Player.

You can always visit my webpage http://padmanijain.googlepages.com/myexperiments.html

Tuesday, May 8, 2007

Download Youtube Videos

Now you can download!!! Youtube Videos. I have added the feature to download videos. All you have to do is to click on this link on the Youtube Player.

I have also update my homepage http://padmanijain.googlepages.com/myexperiments.html .

Friday, May 4, 2007

Suggestions, feedback and comments.

Thank you for using Youtube Player widget. I am committed to making it better. Please leave your suggestions and feedback. They are valuable. I am working on adding the capability to download the Youtube videos.

Wednesday, May 2, 2007

Youtube - TV of Internet

Youtube is becoming the TV of internet, even better your own perosal TV.

From Spiderman 3 to presidential elections, from climate change to bizarre videos - Youtube is becoming a great tool to form opinions. For instance Spiderman3 vides got over 4 million hits on Youtube !!!!4 millions hits!!!! . Youtube will become the TV of internet.

Add this Youtube Player on your webpage.

Tuesday, May 1, 2007

Youtube Player

I have created a YouTube player using the YouTube's RSS APIs. This YouTube player will allow you to search YouTube's videos, play Youtube videos on any web page. It is developed as a Google gadget. (Embed Youtube player on your webpage.)

Following are the main features -
1) Search keywords in Youtube directory.
2) Get a list of all time top rated videos at Youtube.
3) Get a list of most recent videos at Youtube.
4) Add this player on any web page.

Just copy and paste this script in your webpage -


Visit my website for other gadgets.

Comments are welcome so are suggestions and feedback.