E aí galera! Tenho um site de videos adulto e na parte administrativa tem uma opção pra buscar vídeo de outros sites maiores como redtube, xvideos entre outros! O script pega o titulo do video, a descrição, tags, imagem, o código embed e categoria.
Só que há um problema... O do Xvideos não funciona mais!
Eu acredito que seja pq o xvideos mudou um pouco o layout aí o script num consegue pegar...
Tá aí embaixo o código que pega o video do xvideos...
você pode ver aqui preg_match_all('/<td width="183">(.*?)<\/td>/', que ele pega os dados dessa parte do codigo html da pagina... O script é todo assim... vê lá embaixo... Num seu muito PHP mas tentei aprender um pouquinho pra tentar resolver esse problema...
<?php
class MEmbed_xvideos
{
public $url;
public $user_id;
public $category;
public $status;
public $video;
public $errors = array();
public $message;
private $overflow = 500;
public $video_already = 0;
public $video_added = 0;
public function __construct($url, $user_id, $category, $status)
{
$this->url = $url;
$this->user_id = $user_id;
$this->category = $category;
$this->status = $status;
}
public function get_videos()
{
$count = 0;
$curl = new VCurl();
$html = clean_html($curl->saveToString($this->url));
if ($html) {
preg_match_all('/<td width="183">(.*?)<\/td>/', $html, $matches);
if (isset($matches['1'])) {
foreach ($matches['1'] as $match) {
$match = preg_replace('/<script>(.*?)<\/script>/', '', $match);
++$count;
if ($count > $this->overflow) {
$this->errors[] = 'Overflow reached (500)! Aborting!';
return FALSE;
}
$video = array(
'user_id' => $this->user_id,
'site' => 'xvideos',
'url' => '',
'title' => '',
'desc' => '',
'tags' => '',
'category' => '',
'thumbs' => array(),
'duration' => 0,
'embed' => '',
'size' => 0,
'file_url' => '',
'status' => $this->status
);
preg_match('/<script>u:"(.*?)" i:"(.*?)"', $match, $matches_url);
if (isset($matches_url['1'])) {
$video['url'] = trim($matches_url['1']);
if (already_added('xvideos', $video['url'])) {
++$this->video_already;
continue;
}
} else {
continue;
}
preg_match('i:"(.*?)"', $match, $matches_title);
if (isset($matches_title['1'])) {
$video['title'] = strip_tags(htmlspecialchars($matches_title['1']));
}
preg_match('d:"(.*?)"', $match, $matches_duration);
if (!isset($matches_duration['1']) OR !$matches_duration['1']) {
preg_match('/<b>\((.*?)\)<\/b>/', $match, $matches_duration);
}
if (isset($matches_duration['1'])) {
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
}
preg_match('i:"(.*?)"', $match, $matches_thumb);
if (!isset($matches_thumb['1']) OR !$matches_thumb['1']) {
preg_match('/<img src="(.*?)"onMouseOver/', $match, $matches_thumb);
}
if (isset($matches_thumb['1'])) {
$thumb_url = $matches_thumb['1'];
$thumb_url = str_replace('.jpg', '', $thumb_url);
$thumb_url = substr($thumb_url, 0, strrpos($thumb_url, '.'));
$video['thumbs'] = array(
$thumb_url.'.1.jpg',
$thumb_url.'.2.jpg',
$thumb_url.'.3.jpg',
$thumb_url.'.4.jpg',
$thumb_url.'.5.jpg',
$thumb_url.'.6.jpg',
$thumb_url.'.7.jpg',
$thumb_url.'.8.jpg',
$thumb_url.'.9.jpg',
$thumb_url.'.10.jpg',
$thumb_url.'.11.jpg',
$thumb_url.'.12.jpg',
$thumb_url.'.13.jpg',
$thumb_url.'.14.jpg',
$thumb_url.'.15.jpg',
$thumb_url.'.16.jpg',
$thumb_url.'.17.jpg',
$thumb_url.'.18.jpg',
$thumb_url.'.19.jpg',
$thumb_url.'.20.jpg',
$thumb_url.'.21.jpg',
$thumb_url.'.22.jpg',
$thumb_url.'.23.jpg',
$thumb_url.'.24.jpg',
$thumb_url.'.25.jpg',
$thumb_url.'.26.jpg',
$thumb_url.'.27.jpg',
$thumb_url.'.28.jpg',
$thumb_url.'.29.jpg',
$thumb_url.'.30.jpg'
);
}
$video_id = str_replace('http://www.xvideos.com/', '', $video['url']);
$video_id = explode('/', $video_id);
$video_id = $video_id['0'];
if ($video['title'] && $video['duration'] && $video['thumbs'] && isset($video_id)) {
$tags = array();
$tags_arr = explode(' ', strtolower(prepare_string($video['title'], false)));
foreach ($tags_arr as $tag) {
if (strlen($tag) >= 5) {
$tags[] = $tag;
}
}
$video['tags'] = implode(' ', $tags);
$video['embed'] = '<object wmode="transparent" width="'.E_WIDTH.'" height="'.E_HEIGHT.'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://static.xvideos.com/swf/flv_player_site_v4.swf" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="id_video='.$video_id.'" /><embed src="http://static.xvideos.com/swf/flv_player_site_v4.swf" allowscriptaccess="always" width="'.E_WIDTH.'" height="'.E_HEIGHT.'" wmode="transparent" menu="false" quality="high" bgcolor="#000000" allowfullscreen="true" flashvars="id_video='.$video_id.'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
if (add_video($video)) {
++$this->video_added;
} else {
$this->errors[] = 'Failed to add '.$video['url'].'!';
}
} else {
$this->errors[] = 'Failed to get video details for '.$video['url'].'!';
}
}
} else {
$this->errors[] = 'Failed to find video urls on the specified page!';
}
} else {
$this->errors[] = 'Failed to get html code for specified url!';
}
if (!$this->errors) {
return true;
}
return false;
}
private function duration_to_seconds($duration)
{
$duration = str_replace(array(' min', ' sec'), array('m', 's'), $duration);
$duration = str_replace(array('m', 's'), '', $duration);
$duration = explode(' ', $duration);
$seconds = ((int) $duration['0'] * 60);
$seconds = (isset($duration['1'])) ? ($seconds + (int) $duration['1']) : $seconds;
return $seconds;
}
}
?>
Alguém pode me ajudar?