hay te va una clase que todo lo resuelve:
<? $youtube_id = $Video->getLink(); ?>
<?php $youtube = new youtube($youtube_id);?>
<a href="<?php echo $Video->getLink(); ?>" rel="vidbox" title="<?php echo $Video->getTitle(); ?>"><img src="<?php echo $youtube->getUrlImage('grande'); ?>" width="190" height="123"/></a>
clase youtuve
<?php
/*
* Name: Simple Class Info YouTube
* Description: Get Information of video YouTube
* Development: Chuecko
* Site:
http://www.zarpele.com.ar
* License: GNU GENERAL PUBLIC LICENSE (
http://www.gnu.org/licenses/gpl.html)
* Version: 1.0
*/
Código PHP:
Ver originalclass youtube
{
var $data = '';
var $id = '';
public function youtube($id)
{
{
//http://www.youtube.com/v/
//http://youtu.be/-c1ltzu8sKQ
$this->id = $v;
}else{
//var_dump($v);
$this->id = $v[3];
}
}
else
{
$this->id=$id;
}
$url = "http://gdata.youtube.com/feeds/videos/".$this->id;
$browser_id = "none";
(
CURLOPT_URL=>$url,
CURLOPT_HEADER=>false,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>$browser_id
);
$this->data=$server_output;
}
public function getTitle()
{
$startString = "<media:title type='plain'>";
$endString = "</media:title>";
$tempString = strstr($this->data, $startString);
$endLocation = strpos($tempString, $endString); $title = substr($tempString, 0, $endLocation);
{
$title=false;
}
else
{
}
return $title;
}
public function getPublished()
{
$startString = "<published>";
$endString = "</published>";
$starLocation = strpos($this->data, $startString); $tempString = substr($this->data, $starLocation);
$endLocation = strpos($tempString, $endString); $published = substr($tempString, 0, $endLocation);
{
$published=false;
}
else
{
$published=substr($published,0,10); }
return $published;
}
public function getDescription()
{
$startString = "<media:description type='plain'>";
$endString = "</media:description>";
$starLocation = strpos($this->data, $startString); $tempString = substr($this->data, $starLocation);
$endLocation = strpos($tempString, $endString); $description = substr($tempString, 0, $endLocation);
{
$description=false;
}
else
{
}
return $description;
}
public function getMetaTags()
{
$startString = "<media:keywords>";
$endString = "</media:keywords>";
$starLocation = strpos($this->data, $startString); $tempString = substr($this->data, $starLocation);
$endLocation = strpos($tempString, $endString); $metaTags = substr($tempString, 0, $endLocation);
{
$metaTags=false;
}
else
{
}
return $metaTags;
}
public function getUrl()
{
return "http://www.youtube.com/watch?v=".$this->id;
}
public function getUrlImage($option)
{
if($option=='default')
{
return 'http://i.ytimg.com/vi/'.$this->id.'/default.jpg';
}
if($option=='grande')
{
return 'http://i.ytimg.com/vi/'.$this->id.'/0.jpg';
}
if($option==1)
{
return 'http://i.ytimg.com/vi/'.$this->id.'/1.jpg';
}
if($option==2)
{
return 'http://i.ytimg.com/vi/'.$this->id.'/2.jpg';
}
if($option==3)
{
return 'http://i.ytimg.com/vi/'.$this->id.'/3.jpg';
}
}
public function getEmbeb($width, $height)
{
$autoplay = 1;
return '<iframe class="youtube-player" type="text/html" width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$this->id.'?autoplay='.$autoplay.'" frameborder="0">
</iframe>';
}
}
?>