<?php
function getyoutubethumb($videoid)
{
GLOBAL $thumbnail;
$thumbnail = '';
$url = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=lDGXWS_Iw7E&video_id='.$videoid;
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startUTube", "endUTube");
xml_set_character_data_handler($xml_parser, "UTubeData");
if (!($fp = fopen($url, "r")))
{
die("could not open XML input");
}
while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
// ERROR - IGNORE
}
}
xml_parser_free($xml_parser);
return $thumbnail;
}
function getgooglethumb($videoid)
{
$vrss = file_get_contents('http://video.google.com/videofeed?docid='.$videoid);
if(!empty($vrss))
{
preg_match('/<media:thumbnail url="([^"]+)/',$vrss,$thumbnail_array);
$thumbnail = $thumbnail_array[1];
//Remove amp;
$thumbnail = str_replace('amp;','',$thumbnail);
}
return $thumbnail;
}
function getrevverthumb($videoid)
{
return 'http://media.revver.com/broadcast/'.$videoid.'/thumbs/thumb_default.jpg';
}
function startUTube($parser, $name, $attrs)
{
GLOBAL $current_tag;
$current_tag = $name;
}
function endUTube($parser, $name)
{
}
function UTubeData($parser, $data)
{
GLOBAL $thumbnail,$current_tag;
if($current_tag == 'THUMBNAIL_URL')
{
$thumbnail.= $data;
}
}
?>