In what I intend to be the last post in the series for a while – maybe – here’s a quick hack around the Guardian Open-Platform Content API that shows how to “annotate” a particular set of articles (specifically, recent video game reviews) with video trailers for the corresponding game pulled in from Youtube, and then render the whole caboodle in a Grazr widget.
So let’s begin…
Take one Guardian API query:
http://api.guardianapis.com/content/search?filter=/global/reviews&filter=/technology/games&api_key=MYSECRETACTIVATEDAPIKEY we construct the URI and call the webservice:
Here’s a typical result:
As with the football results map pipe, the linkj-text looks like a good candidate for search query text. So let’s tweak it for use as a search on somewhere like Youtube:
I want to be able to let the user choose trailer or review videos, which is why I cleared the search string of the word “review” first, before adding the user preference back into the string.
Now run a Youtube GData/API search using an old pipe block I found laying around (Youtube video search pipe) and grab the top result:
Now I happen to know that if you give a Grazr widget a feed with enclosure.url attributes that point to a flash file, it will embed the flash resource for you:
So now we can take the RSS output of the pipe and pop it into a Guardian game review with video previews Grazr widget:
(The widget layout is customised as described in part in Setting the 3 Pane divider positions.)
If you want to grab the widget and embed it your own webpages, it’s easy enough to do so (although not on hosted WordPress blogs). Simply click on “Share” and select “Customize” from the widget menu bar:
Then you can customise the widget and grab an embed code, or a link to a full screen view:
Good, eh? ;-)
PS Grazr (which is actually an OPML viewer as well as an RSS viewer) embeds other stuff too. For example, here it as as a slideshare viewer; and here it is showing how to automatically generate embedded players for Youtube videos and MP3 audio files using delicious Feed Enhancer – Auto-Enclosures pipe. (If you’re into a bit of hackery, it’ll carry Scribd iPaper too: Embed Scribd iPaper in Grazr Demo. I’m guessing you should be able to get it to embed arbitrary flash games as well?)