9

I'm wordering how apps such as Video DownloadHelper work.


Any ideas?

RadiantHex
  • 24,907
  • 47
  • 148
  • 244

2 Answers2

16

UPDATE: This answer may now be outdated, see comments below. This was going to happen eventually anyway, as YouTube phases out FLV and shifts toward HTML5 video...

They simply resolve the link to the actual FLV file, and download it.

This is done by copying the video identifier from the URL:

http://www.youtube.com/watch?v=WEeqHj3Nj2c

Which is used to request info about the video:

http://www.youtube.com/get_video_info?&video_id=WEeqHj3Nj2c

The video info includes a TOKEN, which you can then you use to make another request:

http://www.youtube.com/get_video?video_id=WEeqHj3Nj2c&t=TOKEN

If all goes well, YouTube will respond with HTTP 303 See Other, including a Location header with a direct link to the FLV file.

Dolph
  • 49,714
  • 13
  • 63
  • 88
  • 1
    thanks for this!!! This is great, I suppose I can do the same for most of other sites too? – RadiantHex Jul 03 '10 at 21:56
  • 5
    Yes, every site has the FLV available *somewhere*. YouTube is likely more difficult than most! Fire up a tool like FireBug to monitor the transaction between your browser and the server to figure out where the FLV's are tucked away. – Dolph Jul 03 '10 at 21:57
  • hey dolph, I tried your steps.After getting the token I tried to fetch the header but youtube returned only 301.. I used curl to fetch headers which returned 301 when I use get_headers I got 200 header which doesn't have file location. whats the possible error occurred here? – Jeyaganesh Mar 13 '11 at 09:31
  • 1
    It appears my answer might be outdated now. If anyone wants to break down the revised process, start by monitoring your HTTP request/response traffic while loading a YouTube page (I use Firebug and/or Chrome Developer Tools, but anything similar will work)... you should be able to see the process and then trim out the steps that are unnecessary. If you succeed, share your results! – Dolph Mar 13 '11 at 17:08
0

Looking at the extension code, you can see it's doing it by regex parsing HTTP responses for various content types. The code is located in network-probe.js.

Specifically its using the http-on-examine-response event in the Firefox addon sdk - https://developer.mozilla.org/en-US/docs/Observer_Notifications#HTTP_requests

Sharun
  • 2,030
  • 4
  • 22
  • 36