« Google Gears Rocks! | Main | Google Gears: ResourceStore and same-orgin policy »

May 31, 2007

Update: Getting YouTube Video (FLV) URL

It seems, YouTube has started using Google cache-servers to serve Flash-Videos (FLV). There is now very easy way to get YouTube FLV files.

http://cache.googlevideo.com/get_video?video_id=<video_id>

That's it, video_id can be found at various places:-

If you click on following link, you would be prompted to download flv :)

http://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ&origin=youtube.com

Update (Jan 11, 2008): Updated the URL for getting FLV from Google Cache server. Thanks to Rohan for sharing updated URL format.

Update: It seems cache.googlevideo.com doesn't work, atleast not for me?

Technorati tags: , , ,

Posted by Abdul Qabiz at May 31, 2007 09:47 PM

Comments

Many thanks for the trick.

It is one step less to access the video from a Flash animation when you only have the video URI. The old way asks to first download the page was so boring.

Posted by: Tek at May 31, 2007 11:17 PM

My understanding is that YouTube have been pretty reluctant to let people access their videos directly, and some people have recieved cease and desist letters regarding players they had made.

This is really cool though. I just hope they don't close it

Posted by: Tony at June 1, 2007 03:36 AM

This is cool. Now that there are several thousand ways to download YouTube videos, why doesn't YouTube actually start offering them on their website. It saves an extra click..

Posted by: Anand at June 1, 2007 12:03 PM

thanks abdul, for a second i thought that my Ip was banned... as my old method of proviring the flv url stopped working.. this was a lifesaver !!!

btw: i'm not downloading videos from youtube, i'm indexing them and streaming it directly over the web :-)

Posted by: Rohan Pinto at June 6, 2007 10:41 AM

THANK YOU. There was a video on YouTube that I really liked, but the author set the video to "private" because she was using copyrighted music in it. I have been looking everywhere to try to get the video and download it, and finally found it now!! Thanks for your trick!! I owe you a lot :)

Posted by: Laurent at June 8, 2007 04:11 PM

Great find (again :))!
Although the URL you provided doesn't lets you download 'old' youtube ID's/video's.
Use this one instead:
http://rd.cache.l.google.com/get_video?video_id=
PS: Could be just IE again though, but the above link works for IE as well :)

Posted by: NeWbY at June 8, 2007 08:03 PM

Hi, salam
i need some Help. i want to play youtube video from mediaPlayback player in flash. so what should i do for it . i also use your ActionScript2.0 in which splitting technique is uesd for flv url but it is not workng plz help out to et this prob
thanks

Posted by: sohail at June 12, 2007 02:45 AM

Thanks for that valuable source of information, helped me no end :)

Posted by: newtriks at June 17, 2007 04:20 AM

Can you please post the YouTubeClientSideDemoFlex.fla cose the youtube_flv_url_test_as2.fla it not work.
thanks

Posted by: Xenofon at June 21, 2007 04:38 PM

I've been trying for days to figure out how to glean the actual file path to the .flv from pointers like http://cache.googlevideo.com/get_video?video_id= via php but have been largely unsuccessful.

The closest I came was through the stream_get_meta_data() function, but even that only returned other get_video.php paths.

Is there any way to find the actual hard link to the flv file for youtube videos?

Posted by: mike at June 22, 2007 03:23 AM

@Xenofon: There is no fla for that, the code you saw in that post, save it in a .mxml file and compile using Flex2SDK or FlexBuilder 2.

@mike: YouTube/Google both do HTTP 302/303 redirection. YouTube required "t" param along with video_id and it forwarded to one of their CDN server..

Things are dynamic in nature and I don't think, there is a hardlink (afaik), but you can save the video_ids and program your player in a way that it loads videos through either cache.googlevideo.com or old way (you would need t param).

-abdul

Posted by: Abdul Qabiz at June 22, 2007 03:23 PM

The problem with programming the video player is that I actually know very little about AS and am using a pre-built player. Whatever reference I use has to be on the PHP level, sadly enough.


As for the filepath, that's the weird part. stream_get_meta_data SOMETIMES returns a hard path to the FLV.

Take, for example, http://youtube.com/watch?v=xCAeq5kE0Ko

Using the s_g_m_d() function, the following locations return:

http://lax-v284.lax.youtube.com/get_video?video_id=xCAeq5kE0Ko
http://cache.googlevideo.com/get_video?video_id=xCAeq5kE0Ko
http://sjc-v166.sjc.youtube.com/get_video?video_id=xCAeq5kE0Ko

and then, finally:

http://youtube-769.vo.llnwd.net/d1/01/F8/xCAeq5kE0Ko.flv

There is no rhyme or reason to which one returns, and if I put the function on a loop, I could wind up with a dozen pointers before the hard path comes back. Meanwhile other YouTube urls might return only the pointer and never the hard path.

It's looking more and more like I'll have to figure out how to make the AS just use the cache location. I just wish I could understand why the path returns sometimes but not all the time.

Posted by: mike at June 23, 2007 12:18 AM

Thank you Abdul, I've got this to work very fine now. Btw, can you work with GoogleVideo as well?

Posted by: Transformer at July 1, 2007 05:12 PM

@Transformer: Google gives you path of FLV for all of it's videos. But remember, Google-Video now aggregates videos from other destination sites (Veoh, Metacafe etc) so you might not get the flv-path for those sites.

Look at Google-Video RSS feeds and filter for all videos uploaded to Google-Video, you get videos in different formats including flv.

-abdul

Posted by: Abdul Qabiz at July 1, 2007 06:44 PM

Love all your posts on this subject abdul... but I'm still a bit confused on how I implement any of this... especially with your code you posted back in April.

I'm a designer and I'm just looking for a simple way to play videos in a custom player... any chance you could dumb it down a bit for the coder-challenged?

Posted by: Eric West at July 4, 2007 12:26 PM

A couple of questions: If I click on your get_video link, the file has no extension after downloading. Should I rename it to .flv? And also, if I put the get_video URL into an address bar with a different (or your) video_id, the download doesn't start. What am I doing wrong? Thanks.

Posted by: Colin at July 19, 2007 07:43 AM

@Eric: You can easily design custom player, you need to understand the logic of getting FLV url from video_id. I would post a clean example, if I get sometime. But you can check out my other posts, I had another example posted, check it out if you can make any use of it.


@Colin: Right, there is no extension for file because YouTube/Google servers throw video/x-flv (video/flv) content-type...You can save it as .flv without any problem.

I just checked, URL with different video_id works. Not sure, why it's not working for you.

Thanks

-abdul

Posted by: Abdul Qabiz at July 21, 2007 08:22 PM

That's HUGE! I've been searching for a way to embed youtube hosted flvs in my swfs. Works great! Thanks!

Posted by: Mike Troy at September 29, 2007 02:19 AM

hai dude,

i created custom video player and i embeded the video player in my page.I want to play youtube video (i did'nt get the youtube filepath)
how should i play the video in my page.

Posted by: pavan1919 at October 11, 2007 06:08 AM

Hi all. But how to get exact url of youtube flv file. I want to get that using php since i want to use jw flash player with youtube playlist.Hope you guys help me with it.Thanks

Posted by: method at October 16, 2007 02:18 PM

abdul,

yes, I noticed that cache.googlevideo.com started throwing BAD request from yesterday... and youve updated this post to point the fact out...

but here's a way around what google's done to prevent it.

http://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ&origin=youtube.com [WORKS]

http://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ [DOES NOT WORK]


cheers :-)
add &origin=youtube.com to the string ;-)

example

Posted by: Rohan at October 19, 2007 10:12 PM

This is currently not working. It's not really reliable anymore. check out this: http://www.jeroenwijering.com/?thread=6483&edit=40806

greets

bmxaction.net

Posted by: wessite at October 20, 2007 12:17 AM

Seems this no longer works.

http://cache.googlevideo.com/get_video?video_id=[videoid]

Returns:

Bad Request
Your client has issued a malformed or illegal request.

Posted by: eeee at October 20, 2007 01:08 AM

http://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ

Google cache links for youtube videos no longer work. Do you know if Google has issued any sort of statement on the matter?

Posted by: Mike Troy at October 20, 2007 01:38 AM

@Rohan: The other URL works for me, even without adding origin param.

@eee, Mike Troy: As per my understanding, videos uploaded after YouTube's acquisition by Google can be downloaded from Google-Cache (cache.google.com)...Other old videos are still on YouTube's CDN.

-abdul

Posted by: Abdul Qabiz at October 22, 2007 02:38 PM

thank abdul &give url suggestion i can not find it

Posted by: bunty at October 28, 2007 02:16 PM

Hi,

I'm having a wierd issue here. The video's play perfect in the MediaPlayback component. But they don't in the FLVPlayBack component and i cant find why...?

Also i tried to use "http://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ&.flv"
but that dousn't work either.

Anyone an idea?

Posted by: CoolCow at November 6, 2007 04:23 PM

@CoolCow: That url doesn't work. Remember, not all videos can be accessed via cache.googlevideo.com, only videos uploaded after YouTube's acquisation...

You might want to try it using other technique (using php proxy or actionscript code), both of them are mentioned on my blog...

Thanks

-abdul

Posted by: Abdul Qabiz at November 7, 2007 02:59 PM

adding origin seems to work

example
http://cache.googlevideo.com/get_video?video_id=[ID]&origin=s.youtube.com

Posted by: anony at November 13, 2007 05:42 AM

*UPDATE*

It doesn't work on all youtube videos, but adding ( &origin=1 ) after the cache url seems to do the trick. You can add any symbol, letter or number after the equals sign and it works.

The old way works on all videos. Enter the embedding code for the video in your browsers address bar. When it loads replace ( /swf/l.swf? ) with ( get_video? )

Posted by: RAMBO at November 19, 2007 02:40 AM

well mine doesnt work can anyone help
7usTgw-7XfM

Posted by: XP GUY at November 20, 2007 09:47 AM

Well I read all these comments. I know how to embed a youtube video into HTML (the program creates the bloody code for you!), but I'm curious to know how I could embed the youtube video player IN the flash movie itself? Any ideas? I assume I have to make a graphic symbol the size of the player (455x385) then add some code to it, but what?

Posted by: Myron at December 7, 2007 09:20 PM

the answer to FLVPlayback problem is adding this in NCManager.as, line 276 after the if condition.
it should now accept parameters passed to contentPath.

else{
_isRTMP = false;
_streamName = parseResults.streamName;
return (canReuse || connectHTTP());

}

Posted by: Yehia Shouman at December 11, 2007 05:59 PM

I've just posted up a solution on my blog that may help others on how to get the direct url path to .flv video files on YouTube for Free.

It's not dynamic but a quick trick to get the path.

View it here >> "How to get the direct url path to .flv video files on YouTube for Free"

Hope this helps...

Posted by: Kieran McCarthy at December 15, 2007 12:42 AM

Yeah! It works very fine!! Thank you Abdul Qabiz !!!!! You're so kind !!
Others are more likely to earn more money from that php codes, you are a cool man !!!

Posted by: liloli at December 22, 2007 06:08 PM

Does Anyone know how to do the same for BrightCove Videos http://studio.brightcove.com/

the youtube way doesn't work for a video using the brightcove player

Posted by: Richard Prior at December 23, 2007 10:19 PM

hi..i try to download a video in www.person.com,,the url are given but if i try to download it i can download,what should i do so i can download that video...

Posted by: Rodz at January 7, 2008 04:58 PM

All you have to do is find the video location because they moved it from google video servers. To do that use web http://keepvid.com/ where you copy/paste the youtube video url and click on Donwload button. Then link "Download link" appears and you have to substitute the old "cache.google.com" by eg. "ash-v286.ash.youtube.com" that's all. The bad news is that you have to do that manually for each video :/

Posted by: Tomek at January 7, 2008 10:15 PM

@Rohan: Thanks, I have updated my post above with the tip you gave. Google throws error without origin=youtube.com param in URL.

-abdul

Posted by: Abdul Qabiz at January 11, 2008 11:36 PM

tnx for the help...

Posted by: Rodz at January 17, 2008 06:43 AM

hi tomek... it is posible that i can download a movie whos not playing..like in www.person.com the video i was trying to download is the video has unsafe content..f i try to play the video there is a message say;'only the premium member can view'i want to download a video from that site using the url they given...pls help me..kindly send your answer to my email add.panther_walsk22@yahoo.com

Posted by: Rodz at January 17, 2008 08:35 AM

This method used to work really well. However it would seem that as of this morning, Jan. 24, Youtube have changed something such that get_video? no longer works. It returns a blank screen.

Posted by: Rhino at January 25, 2008 02:25 AM

This is really nice, but it only works for video who got posted for some time, If you use YouTubeLoader to download your youtube videos you can even download the most recent onces

Posted by: Aribo at January 26, 2008 10:19 PM

Please check out this player! It playing YouTube videos and also H.264 video and/or HE-AAC audio.

Posted by: Bogdan at February 9, 2008 03:57 AM

hi abdul... it is posible that i can download a movie whos not playing..like in www.person.com the video i was trying to download is the video has unsafe content..f i try to play the video there is a message say;'only the premium member can view'i want to download a video from that site using the url they given...pls help me..kindly send your answer to my email address.panther_walks22@yahoo.com

Posted by: rodz at February 9, 2008 09:21 AM

Sorry, the above link that I gave doesn't work anymore. Check out this great player!.

Posted by: b0ggy at February 13, 2008 03:05 PM

i have dozens of players and downloaders, but a lot of youtube vids will not play, it says not flv file,
how do i find out what the formatt is as i want to convert some of them for dvd or vcd, or are they not ment to b converted.
thanks pete

Posted by: pete at March 3, 2008 08:09 PM

http://gootube.kej.idv.tw/

That's all!

Posted by: Homecut at March 14, 2008 11:29 PM

the answer to FLVPlayback problem is adding this in NCManager.as, line 276 after the if condition.
it should now accept parameters passed to contentPath.

else{
_isRTMP = false;
_streamName = parseResults.streamName;
return (canReuse || connectHTTP());

}


I am using Flash CS3 on OS X and within NCmanager.as at line 276 it does not have an if statement. I found the NCmanager.as file in the directory Flash CS3>Configuration>Component Source>ActionScript 3.0>FLVPlayback>fl>video

I was able to get the urlhttp://cache.googlevideo.com/get_video?video_id=M0ODskdEPnQ&origin=youtube.com to playback using the Media Component in Actionscript 2.0 but can't get it to play with the Flvplayback component in either Actionscript 2 or 3. Can anyone figure how to play using FLVplayback component??

Posted by: Thien at April 11, 2008 03:11 AM

I have several youtube players on my website that I set up to play my own playlists of videos I found on youtube. 2 of the players aren't always on my playlist when I log onto the site. When this happens I have to go back to my custom player, make a minor edit on the description or something, then hit save and finish and the player is fixed. But 3 or 4 visits later it's back on the wrong video. usually the same wrong video. Any suggestions?

Posted by: Ken at April 16, 2008 07:26 AM

Hello,

I have a cache-server that is caching youtube flv video. Somewhere in Feb 2008, I notice that youtube return new parameters on the URL for download...client ip address..signature...

This makes every individual download unique if the clients are of different ip. From my cache-server, all flv files are missed. Any ideas on this?

Thanks.

Example

Previously
http://cache.googlevideo.com/get_video?video_id=9RkS1xRKMN0&origin=nyc-v198.nyc.youtube.com

Now
http://cache.googlevideo.com/get_video?video_id=9RkS1xRKMN0&origin=nyc-v198.nyc.youtube.com&signature=A91E6F00ADEBEF2979524CBB9A956FB05991BFF4.A11163461BD10C91B85CB80D073AEAA58E6A69EB&ip=x.x.x.x&ipbits=16&expire=1210324387&key=yt1&sver=2

Posted by: petepo at May 9, 2008 09:57 AM

well mine doesnt work can anyone help
7usTgw-7XfM
the same

Posted by: audai at May 10, 2008 04:51 AM

tried all the youtube URL's given here, none of them works anymore (if they ever worked), so guys quit the search, it's not worth it. The URL's generated are pure dynamic, just include youtube player and enjoy the video.

Posted by: abdul at August 7, 2008 07:03 PM

In some countries You Tube has been filtered due to strict Internet policies like Iran, Turkey, Tailand ,...
Is there anyway to bypass the filter and download the clip from youtube since all the youtube IP ranges have been snuffed out?

Posted by: Lucifer at September 10, 2008 07:59 AM

Problem Solved!
Just check out the following website
Enter the url and get your favorite clip
You can also check Auto-Download to D.L your stuff from the page.
Otherwise you'll be given a code.

http://kej.tw/flvretriever/

Posted by: Emandem at September 10, 2008 02:25 PM

how are you getting the URL from the youtube video_id?

Posted by: guyjj at October 1, 2008 06:25 AM

This posting (http://eduviews.com/portal/getting-youtube-video-url) is an explanation of how to resolve the video_id into a genuine flv. This can be done directly in an .AIR application (see the example), OR if you are using a straight Flash player then you can implement this code as a proxy on your server.

Hope this helps some of you.

Posted by: paulg at October 20, 2008 06:59 AM

I thought the AIR example might be too complicated for some, so I changed the example (http://eduviews.com/portal/getting-youtube-video-url) to demonstrate how this is done with Flash/Flex and a php proxy.

Posted by: paulg at October 21, 2008 01:56 AM

Hi It was so useful for me. But since last week the program doesn`t work. I think the U-tube change url method or thet don`t want to acess like this way. I really want to use this program again. so do U have another way to use it?? thank you for you`re kindness Bye :-)

Posted by: kay at October 26, 2008 01:21 PM

Hi It was so useful for me. But since last week the program doesn`t work. I think the U-tube change url method or thet don`t want to acess like this way. I really want to use this program again. so do U have another way to use it?? thank you for you`re kindness Bye :-)

Posted by: Kay at October 26, 2008 01:22 PM

Hello,

Thank you Abdul this is a very nice code! too bad I just found it, while it was posted a LONG time ago!

I guess the "http://youtube.com/get_video.php" script is gone because I get no results whatsoever, only 404 error.

While if you run a query for: "http://youtube.com/v/AJRcOF7rEfQ" it works, but you won´t get te 't=' param anymore.


@Abdul

It seems your server does not accept any requests, I keep getting 403 error on all your examples.

Posted by: Mehrad Heidar at November 9, 2008 09:18 PM

Post a comment




Remember Me?


Please enter the security code you see here

(you may use HTML tags for style)