YouTube/JSONP oEmbed service "oembed-js"

In the previous post I introduced my oembed-js service and an application using it: YouTube embeds in Blogger comments.



Oembed-js is a Google Appengine application coded in Python. It relays YouTube oembed calls and offers results also in JSONP format, so javascript applications can use it.



Parameters



url: the (youtube) url to embed (best to be urlencoded)

maxwidth: max width of embedded object (optional)

maxheight: max height of embedded object (optional)

format: json/jsonp or xml (optional, default:json/jsonp)

callback or jsonp: the javascript callback function, required, if jsonp format is wanted

callID: a call ID that is passed through to response (optional)



Sample call:



http://oembed-js.appspot.com/?callback=foo&callID=123&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGMra5Wh51oU



Response



YouTube oEmbed response in json(p) or xml format, including field html (see oembed specs), and:



callID: if callID was given, it is passed through (can identify the response)

url: pass through the url that is being embedded

videoid: contains 11 char long YouTube videoid, if single video embed

playlist: contains playlist id, if playlist embed



Sample response:



foo({"provider_url": "http://www.youtube.com/", "version": "1.0", "title": "Sviatoslav Richter in Kiev, 1958 - Pictures at an Exhibition", "url": "http://www.youtube.com/watch?v=GMra5Wh51oU", "type": "video", "videoid": "GMra5Wh51oU", "thumbnail_width": 480, "height": 344, "width": 459, "html": "<iframe width=\"459\" height=\"344\" src=\"http://www.youtube.com/embed/GMra5Wh51oU?fs=1&feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>", "author_name": "FirstPublicChannel", "callID": "123", "provider_name": "YouTube", "thumbnail_url": "http://i4.ytimg.com/vi/GMra5Wh51oU/hqdefault.jpg", "thumbnail_height": 360, "author_url": "http://www.youtube.com/user/FirstPublicChannel"})



Another demo how to use it



Enter YouTube URL (video or playlist):



 



This demo and its source is also here in this jsFiddle.








Update March 27th 2012: Now oembed-js supports youtu.be urls (YouTube oembed service does not support them). Also now supports videos which have embedding turned off (YouTube oembed does not support these either).