Monday 11 February 2008

Working again : redirection quirkies

One of the tricks to making this work is finding the correct url for the Flash Video flv to pass into the player.

Typically youtube tell you it's something like
  http://chi-v62.chi.youtube.com/get_video?video_id=8EyOlP9IyFg

Where the subdomain of youtube.com and the video_id are variable.

This is easy - pop .flv on the end and it's what you need to feed into the Flash client.

However sometimes youtube tell you it's
  http://cache.googlevideo.com/get_video?video_id=8EyOlP9IyFg&origin=chi-v62.chi.youtube.com

which contains the same data, but needs to be monkey'd with to reconstruct it into the correct form.

Then over the weekend we found another variation:
  http://chi-v304.chi.youtube.com/get_video?video_id=f4RWiK_cjjs&signature=xxxx.xxxx&ip=x.x.x.x&ipbits=16&expire=1202749500&key=1

which again contains all the interesting information, plus a load more.

Note: the signature and ip values have been blanked.

There are almost certainly more. This is the sort of rubbish you shouldn't have to deal with when using an API. Except what we are doing is not actually something made available via an API.

GoogleTube let you embed the video into your own webpages but only if you use the GoogleTube flash player. I'd love to do that, except it doesn't let you find out when the video has finished playing and thus makes providing a constant stream of videos near impossible.

So we need to use a custom flash player, and that requires the flv urls to be in a specific format. A format you can work out, but not take directly from any API or feed. Bah.

No comments: