Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/dojki.php
Строк: 97
<?php
defined('_VALID') or die('Restriced Acess!');
define('_RESIZE_THUMB', TRUE);
class VComponent_Admin_grab_dojki 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('/<td>(.*?)</td>/', $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' => 'dojki',
'url' => '',
'title' => '',
'desc' => '',
'tags' => '',
'category' => '',
'thumbs' => array(),
'duration' => 0,
'embed' => '',
'size' => 0,
'file_url' => ''
);
preg_match('/<a href="(.*?)"> <img id=/', $match, $matches_url);
if (isset($matches_url['1'])) {
$video['url'] = trim($matches_url['1']);
$video_id = str_replace('/', '', $video['url']);
$video['url'] = 'http://www.dojki.com'.$video['url'];
$this->update_progress($progress.'^Processing '.$video['url']);
if ($this->already_added('dojki', $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('/<div id="time">(.*?)</div>/', $match, $matches_duration);
if (isset($matches_duration['1']) && $matches_duration['1']) {
$duration = substr($matches_duration['1'], 0, strrpos($matches_duration['1'], ' '));
$video['duration'] = $this->duration_to_seconds($duration);
}
preg_match('/data-original="(.*?)"/', $match, $matches_thumb);
if (isset($matches_thumb['1'])) {
$thumb_url = $matches_thumb['1'];
$thumb_url = substr($thumb_url, 0, strrpos($thumb_url, '/'));
$video['thumbs'] = array(
$thumb_url.'/thumb1.jpg',
$thumb_url.'/thumb2.jpg',
$thumb_url.'/thumb3.jpg',
$thumb_url.'/thumb4.jpg',
$thumb_url.'/thumb5.jpg',
$thumb_url.'/thumb6.jpg',
$thumb_url.'/thumb7.jpg',
$thumb_url.'/thumb8.jpg',
$thumb_url.'/thumb9.jpg',
$thumb_url.'/thumb10.jpg',
$thumb_url.'/thumb11.jpg',
$thumb_url.'/thumb12.jpg',
$thumb_url.'/thumb13.jpg',
$thumb_url.'/thumb14.jpg',
$thumb_url.'/thumb15.jpg',
$thumb_url.'/thumb16.jpg',
$thumb_url.'/thumb17.jpg',
$thumb_url.'/thumb18.jpg',
$thumb_url.'/thumb19.jpg',
$thumb_url.'/thumb20.jpg',
$thumb_url.'/thumb21.jpg',
$thumb_url.'/thumb22.jpg',
$thumb_url.'/thumb23.jpg',
$thumb_url.'/thumb24.jpg',
$thumb_url.'/thumb25.jpg',
);
}
preg_match_all('/<a href='(.*?)'>(.*?)</a>/', $match, $matches_tags);
if (isset($matches_tags['2'])) {
$video['tags'] = implode(',', array_values($matches_tags['2']));
}
preg_match('/<br>(.*?)</a>/', $match, $matches_title);
if (isset($matches_title['1']) && $matches_title['1']) {
$video['title'] = trim(strip_tags($matches_title['1']));
}
if ($video['duration'] && $video['thumbs'] && $video['title'] && $video['tags']) {
$video['embed'] = '<iframe src="http://www.dojki.com/embed/'.$video_id.'" frameborder="0" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'" scrolling="no"></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(' 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;
}
}