Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/extremetube.php
Строк: 115
<?php
defined('_VALID') or die('Restriced Acess!');
class VComponent_Admin_grab_extremetube extends VComponent_Admin_grab_grab
{
public function __construct($url, $user_id, $category, $status, $unique)
{
parent::__construct();
$this->url = $url;
$this->user_id = $user_id;
$this->category = $category;
$this->status = $status;
$this->unique = $unique;
}
public function get_videos()
{
$count = 0;
$this->update_progress('0^Parsing remote html...');
$html = $this->clean_html(VCurl::string($this->url, 'iVisited=1; cookAV=1'));
if ($html) {
preg_match_all('/<div class="listing-media">(.*?)s</span><span class="r">/ms', $html, $matches);
if (isset($matches['0']) && $matches['0']) {
$this->update_progress('0^Processing videos...');
$total_videos = count($matches['1']);
$incr = round((100/$total_videos), 2);
$progress = 0;
foreach ($matches['0'] as $match) {
++$count;
if ($count > $this->overflow) {
$this->errors[] = 'Overflow reached (500)! Aborting!';
return FALSE;
}
$video = array(
'site' => 'deviantclip',
'url' => '',
'title' => '',
'desc' => '',
'tags' => '',
'category' => '',
'thumbs' => array(),
'duration' => 0,
'embed' => '',
'size' => 0,
'file_url' => ''
);
preg_match('/<a href="(.*?)" title="(.*?)">/', $match, $matches_url);
if (isset($matches_url['1']) && isset($matches_url['2'])) {
$video['url'] = $matches_url['1'];
$video['title'] = strip_tags(stripslashes($matches_url['2']));
$this->update_progress($progress.'^Processing '.$video['url'].' ('.$video['title'].') ...');
if ($this->already_added('redtube', $video['url'])) {
$this->update_progress($progress.'^Video already added!');
$progress = sprintf("%01.2f", ($progress+$incr));
++$this->video_already;
continue;
}
} else {
$this->update_progress($progress.'^Failed to find video title...continue!');
$progress = sprintf("%01.2f", ($progress+$incr));
continue;
}
preg_match('/Media-(.*?)_/', $video['url'], $match_id);
if (isset($match_id['1']) && $match_id['1']) {
$video_id = $match_id['1'];
}
preg_match('/<span class="stats"><span>(.*?)</span>/', $match, $matches_duration);
if (isset($matches_duration['1'])) {
$video['duration'] = $this->time_to_seconds($matches_duration['1']);
}
preg_match("/['http://thumbs.deviantclip.com/(.*?).jpg',/", $match, $matches_thumb);
if (isset($matches_thumb['1']) && $matches_thumb['1']) {
$thumb_url = $matches_thumb['1'];
$thumb_arr = explode('-', $thumb_url);
$thumb_url = 'http://thumbs.deviantclip.com/'.$thumb_arr['0'];
$video['thumbs'] = array(
$thumb_url.'-0001.jpg',
$thumb_url.'-0002.jpg',
$thumb_url.'-0003.jpg',
$thumb_url.'-0004.jpg',
$thumb_url.'-0005.jpg',
$thumb_url.'-0006.jpg',
);
}
if ($video['title'] && $video['duration'] && $video['thumbs'] && isset($video_id)) {
$content = $this->clean_html(VCurl::string('http://deviantclip.com'.$video['url']));
preg_match('/<span>Tags:(.*?)</span>/', $content, $match_tags);
if (isset($match_tags['1']) && $match_tags['1']) {
preg_match_all('/<a href="(.*?)">(.*?)</a>/', $match_tags['1'], $matches_tags);
$tags = array();
if (isset($matches_tags['2'])) {
foreach ($matches_tags['2'] as $tag) {
$tags[] = strtolower(prepare_string($tag));
}
$video['tags'] = implode(' ', $tags);
}
}
$video['embed'] = '<embed src="http://www.deviantclip.com/flashplayer/flvplayer.swf" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'" menu="false" quality="high" bgcolor="#ffffff" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" flashvars="enablejs=true&autostart=true&mediaid='.$video_id.'&displayclick=link&linktarget=_blank&backcolor=0xcd9b8d&frontcolor=0xebdbd4&lightcolor=0xffffff&streamer=lighttpd" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
if ($this->add_video($video)) {
++$this->video_added;
$progress = sprintf("%01.2f", ($progress+$incr));
$this->update_progress($progress.'^Video ('.$video['url'].') embedded!');
} else {
$this->update_progress($progress.'^Failed to add video database entry!');
$progress = sprintf("%01.2f", ($progress+$incr));
$this->errors[] = 'Failed to add '.$video['url'].'!';
}
} else {
$this->update_progress($progress.'^Failed to get video details for '.$video['url'].'!');
$progress = sprintf("%01.2f", ($progress+$incr));
$this->errors[] = 'Failed to get video details for '.$video['url'].'!';
}
}
} else {
$this->update_progress('100^No videos found while parsing remote html!!!');
$this->errors[] = 'No videos found while parsing '.$this->url.'!';
}
} else {
$this->update_progress('100^Failed to download remote html page!!!');
$this->errors[] = 'Failed to download '.$this->url.'!';
}
if ($this->errors) {
return FALSE;
}
return TRUE;
}
private function time_to_seconds($duration)
{
$duration = str_replace(' ', '', $duration);
$duration = str_replace('s', '', $duration);
$duration = explode('m', $duration);
if (isset($duration['1'])) {
return ((int) $duration['0']*60) + (int) $duration['1'];
}
return (int) $duration['0'];
}
}