Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/pornrabbit.php
Строк: 103
<?php
defined('_VALID') or die('Restriced Acess!');
define('_RESIZE_THUMB', TRUE);
class VComponent_Admin_grab_pornrabbit 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));
if ($html) {
preg_match_all('/<div class="video">(.*?)</div></div>/', $html, $matches);
if (isset($matches['1'])) {
$this->update_progress('0^Processing videos...');
$total_videos = count($matches['1']);
$incr = round((100/$total_videos), 2);
$progress = 0;
foreach ($matches['1'] as $match) {
++$count;
if ($count > $this->overflow) {
$this->errors[] = 'Overflow reached (500)! Aborting!';
return FALSE;
}
$video = array(
'site' => 'pornrabbit',
'url' => '',
'title' => '',
'desc' => '',
'tags' => '',
'category' => '',
'thumbs' => array(),
'duration' => 0,
'embed' => '',
'size' => 0,
'file_url' => ''
);
preg_match('/<a href="(.*?)" title="(.*?)"><h2>/', $match, $matches_url);
if (isset($matches_url['1']) && $matches_url['1'] &&
isset($matches_url['2']) && $matches_url['2']) {
$video['url'] = 'http://www.pornrabbit.com'.trim($matches_url['1']);
$video['title'] = strip_tags(htmlspecialchars($matches_url['2']));
$this->update_progress($progress.'^Processing '.$video['url'].' ...');
if ($this->already_added('pornrabbit', $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 url...continue!');
$progress = sprintf("%01.2f", ($progress+$incr));
continue;
}
preg_match('/<span>runtime: <b>(.*?)</b></span>/', $match, $matches_duration);
if (isset($matches_duration['1'])) {
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
}
preg_match('/<img src="(.*?)" class="thumb/', $match, $matches_thumb);
if (isset($matches_thumb['1'])) {
if (strpos($matches_thumb['1'], '_') === FALSE) {
$this->update_progress($progress.'^Video embedded from xhamster...continue!');
$progress = sprintf("%01.2f", ($progress+$incr));
continue;
}
$thumb_arr = explode('_', $matches_thumb['1']);
$thumb_url = $thumb_arr['0'];
$video['thumbs'] = array(
$thumb_url.'.jpg',
$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'
);
}
$video_arr = explode('/', $video['url']);
$video_id = $video_arr['4'];
if ($video['title'] && $video['duration'] && $video['thumbs'] && isset($video_id)) {
$tags = array();
$tags_arr = explode(' ', strtolower(prepare_string($video['title'])));
foreach ($tags_arr as $tag) {
if (strlen($tag) >= 5) {
$tags[] = $tag;
}
}
$video['tags'] = implode(' ', $tags);
$video['embed'] = '<iframe src="http://www.pornrabbit.com/embed/'.$video_id.'/" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'" frameborder="0" scrolling="0" border="0" style="overflow: hidden;"></iframe>';
if ($this->add_video($video)) {
$progress = sprintf("%01.2f", ($progress+$incr));
$this->update_progress($progress.'^Video ('.$video['url'].') embedded!');
++$this->video_added;
} 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;
}
protected function duration_to_seconds($duration)
{
$duration = str_replace(array('m', 's'), array(':', ''), $duration);
$duration = explode(':', $duration);
$minutes = sprintf('%01d', $duration['0']);
$seconds = sprintf('%01d', $duration['1']);
return (($minutes * 60) + $seconds);
}
}