
Overcoming the Lack of a Hulu API
Today I’m building a web app that provides a live listing of all available Criterion films. There are two places (mainly) that stream these movies: Netflix and Hulu.
Doing searches against Netflix is very easy, thanks to their incredible openness and the APIs they make available. I specifically use their OData provider—all I have to do is structure a URL which contains a query. I wrote the function to do this search in under 5 minutes!
Querying Hulu is, however, much more difficult. They don’t have any sort of official API, unfortunately. After some digging, though, I found out that they support oEmbed. I’d never heard of oEmbed, but it is meant to convey the metadata about any particular item offered on a site. I eventually found an old Hulu blog post from 2008, announcing oEmbed support.
oEmbed won’t help me do any searches, but it will (thankfully) allow me to retrieve structured information after I find the video I want.
For example, if I want information about the video at http://www.hulu.com/watch/20807/late-night-with-conan-obrien-wed-may-21-2008, then the oEmbed URL of:
http://www.hulu.com/api/oembed.json?url=http%3A//www.hulu.com/watch/20807/late-night-with-conan-obrien-wed-may-21-2008
…will give me a nice response:
{
"thumbnail_width": 145,
"type": "video",
"title": "Wed, May 21, 2008 (Late Night with Conan O'Brien)",
"duration": 2543.98,
"embed_url": "http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w",
"thumbnail_height": 80,
"provider_name": "Hulu",
"width": 512,
"air_date": "Wed May 21 00:00:00 UTC 2008",
"provider_url": "http://www.hulu.com/",
"version": "1.0",
"height": 296,
"cache_age": 3600,
"thumbnail_url": "http://thumbnails.hulu.com/8/500/23678_145x80_manicured__SIXr9mO9sUO3dYt+S-XTIw.jpg",
"html": "<object width=\"512\" height=\"296\"><param name=\"movie\" value=\"http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w\"></param><param name=\"flashvars\" value=\"ap=1\"></param><embed src=\"http://www.hulu.com/embed/0-njKp22bl4GivFXH0lh5w\" type=\"application/x-shockwave-flash\" width=\"512\" height=\"296\" flashvars=\"ap=1\"></embed></object>",
"author_name": "NBC"
}
Now that I know Hulu has an /API/ path on their site, I may have to try digging around to figure out if they’re secretly offering any other functionality. Hopefully someone finds this little discovery a bit helpful!