Cercare su Youtube dinamicamente utilizzando jQuery

Lo script che vi proponiamo oggi permette di cercare su YouTube utilizzando jQuery.
Il parametro "callback=?" abilita jsonp invece di json (corregge errori cross browser in IE), "max-results=5" indica il risultato massimo da visualizzare, "q=SEARCHQUERY" indica il termine da cercare.

 
$.getJSON("http://gdata.youtube.com/feeds/api/videos?callback=?&max-results=5&alt=json&q=SEARCHQUERY", function (data) {
            if (data.feed.entry == null) {
                // If no videos are found, do stuff here
                return false;
            }
            var dataLength = data.feed.entry.length; //how many videos were found
            $.each(data.feed.entry, function (i, item) {
                var title = item['title']['$t']; //get title
                var thumb = item['media$group']['media$thumbnail'][0]['url']; //get thumbnail
                var user = item['author'][0]['name']["$t"]; //get user
                var video = item['id']['$t']; //get url
                video = video.replace('http://gdata.youtube.com/feeds/api/videos/', 'http://www.youtube.com/watch?v=');
                //do stuff here
            });
        });