Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/empflix.php
Строк: 95
<?php
defined('_VALID') or die('Restriced Acess!');
class VComponent_Admin_grab_empflix 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, 'video_type_preview=image'));
if ($html) {
preg_match_all('/<span class="thumb(.*?)<div class="rate/', $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' => 'empflix',
'url' => '',
'title' => '',
'desc' => '',
'tags' => '',
'category' => '',
'thumbs' => array(),
'duration' => 0,
'embed' => '',
'size' => 0,
'file_url' => ''
);
preg_match('/<a href="(.*?)" title="(.*?)"><img/', $match, $matches_url);
if (isset($matches_url['1']) && isset($matches_url['2'])) {
$video['url'] = trim($matches_url['1']);
$video['title'] = strip_tags(stripslashes($matches_url['2']));
if (strpos($video['url'], 'premium') === FALSE) {
$this->update_progress($progress.'^Processing '.$video['url'].' ...');
if ($this->already_added('empflix', $video['url'])) {
$this->update_progress($progress.'^Video already added!');
$progress = sprintf("%01.2f", ($progress+$incr));
++$this->video_already;
continue;
}
} else {
$this->update_progress($progress.'^Video is premium...skipping!');
$progress = sprintf("%01.2f", ($progress+$incr));
continue;
}
} else {
$this->update_progress($progress.'^Failed to find video title...continue!');
$progress = sprintf("%01.2f", ($progress+$incr));
continue;
}
preg_match('/<p class="length">(.*?)</p>/', $match, $matches_duration);
if (isset($matches_duration['1'])) {
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
}
preg_match('/<img src="/images/blank.gif" data-src="(.*?)" alt=/', $match, $matches_thumb);
if (!isset($matches_thumb['1'])) {
preg_match('/<img src="(.*?)" alt/', $match, $matches_thumb);
}
if (isset($matches_thumb['1'])) {
$thumb_url = trim($matches_thumb['1']);
$thumb_arr = explode('-', $thumb_url);
$thumb_left = $thumb_arr['0'];
$video['thumbs'] = array(
$thumb_left.'-1.jpg',
$thumb_left.'-2.jpg',
$thumb_left.'-3.jpg',
$thumb_left.'-4.jpg',
$thumb_left.'-5.jpg',
$thumb_left.'-6.jpg',
$thumb_left.'-7.jpg',
$thumb_left.'-8.jpg',
$thumb_left.'-9.jpg',
$thumb_left.'-10.jpg',
$thumb_left.'-11.jpg',
$thumb_left.'-12.jpg',
$thumb_left.'-13.jpg',
$thumb_left.'-14.jpg',
$thumb_left.'-15.jpg',
$thumb_left.'-16.jpg',
$thumb_left.'-17.jpg',
$thumb_left.'-18.jpg',
$thumb_left.'-19.jpg',
$thumb_left.'-20.jpg',
$thumb_left.'-21.jpg',
$thumb_left.'-22.jpg',
$thumb_left.'-23.jpg',
$thumb_left.'-24.jpg',
$thumb_left.'-25.jpg',
$thumb_left.'-26.jpg',
$thumb_left.'-27.jpg',
$thumb_left.'-28.jpg',
$thumb_left.'-29.jpg',
$thumb_left.'-30.jpg'
);
}
$video_id = explode('-', str_replace('.html', '', $video['url']));
$video_id = end($video_id);
$video['embed'] = '<iframe src="http://player.empflix.com/video/'.$video_id.'" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'" frameborder="0"></iframe>';
if ($video['title'] && $video['duration'] && $video['thumbs'] && isset($video_id)) {
$content = $this->clean_html(VCurl::string($video['url'], 'video_type_preview=image'));
preg_match('/<span class="infoTitle">Categories:</span>(.*?)</li>/', $content, $matches_category);
if (isset($matches_category['1'])) {
preg_match('/<a href="(.*?)">(.*?)</a>/', $matches_category['1'], $match_category);
if (isset($match_category['2'])) {
$video['category'] = strip_tags(stripslashes($match_category['2']));
}
}
preg_match('/<span class="infoTitle">Tags:</span>(.*?)</li>/', $content, $matches_tags);
if (isset($matches_tags['1'])) {
preg_match_all('/<a href="(.*?)">(.*?)</a>/', $matches_tags['1'], $matches_urls);
if (!isset($matches_urls['2']) OR empty($matches_urls['2'])) {
preg_match_all('/<a rel="nofollow" href="(.*?)">(.*?)</a>/', $matches_tags['1'], $matches_urls);
}
if (isset($matches_urls['2'])) {
$tags = array();
foreach ($matches_urls['2'] as $tag) {
$tags[] = prepare_string(strip_tags(stripslashes($tag)));
}
$video['tags'] = strtolower(implode(' ', $tags));
}
}
if ($video['category'] && $video['tags'] && $video['embed']) {
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'].'(embed/tags/category)!');
$progress = sprintf("%01.2f", ($progress+$incr));
$this->errors[] = 'Failed to get video details for '.$video['url'].'(embed/tags/category)!';
}
} 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;
}
public function get_video()
{
}
}