tags:

views:

533

answers:

1

I'm writting FLV media player and want to know if there is there anyway of accessing the underlying FLV files used by YouTube from a URL? There used to be a bunch of ways of doing it, but YouTube have changed things about and I now can't find any way of doing it...

From what I've seen so far, the YouTube API doesn't seem to give access either. Has anyone found a way of doing it?

Cheers!

+6  A: 

There are two values associated with a YouTube video: an ID and a signature. The ID is simple to get, as it's in the URI itself. The signature is a bit trickier to get. It's embedded in a Javascript statement in the source code of each video page.

For example, let's take the Numa Numa video.

It has an ID of KmtzQCSh6xk, as can be seen from the URI.

To get the signature, we have to dig into the source code of the HTML. To easily do this in Firefox, load the source of the page by right clicking anywhere on the page and click "View Page Source." After that, press Ctrl+F, and type in "t":. It will take you to the signature of the page: the value directly after that in quotes is the signature.

In the case of the Numa Numa Dance, it's signature is vjVQa1PpcFOSvCcjdAYSc3ZQgK-6EG9yQM7RLSYqJk4%3D

To get the actual FLV, you enter this URI:

http://www.youtube.com/get_video?fmt=5&video_id={ID}&t={SIGNATURE}

The complete URI to get the FLV video is:

http://www.youtube.com/get_video?fmt=5&video_id=KmtzQCSh6xk&t=vjVQa1PpcFOSvCcjdAYSc3ZQgK-6EG9yQM7RLSYqJk4%3D

You can use this information to help you get the signature and ID you need to download the FLV programatically. Whether it's doing a simple String.Find for the value "t": or using RegEx, it should be simple to find until they change it.

nasufara
I've tried this in IE8 but can't find the signature in the source. I might be doing something wrong, but the URI you've got there also happens to give me a 403 - perhaps it's another method shut down by YouTube...
Tom Allen
Ignore! I found the signature... thanks!
Tom Allen
Is there anyway to parse this information programmatically from the page? When I request the page with a WebRequest, I get a totally different version than I do with the browser (with no signature in it), even if I set the referrer and User Agent.
iZ
I tried this, but I couldn't replicate it. I got a signature, albeit a different one, since they've changed the signature on that video since I wrote this.
nasufara