Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/yobt.php
Строк: 94
<?php
defined
('_VALID') or die('Restriced Acess!');
define('_RESIZE_THUMB'TRUE);
class 
VComponent_Admin_grab_yobt 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'unq=1; interior=1'));
        if (
$html) {
            
preg_match_all('/<div class="thumb" (.*?)</div>/ms'$html$matches);
            if (isset(
$matches['1']) && $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'        => 'yobt',
                        
'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'];
                        if (
strpos($video['url'], 'http://') === FALSE) {
                            
$video['url'] = 'http://www.yobt.com'.$video['url'];
                        }
                        
                        
$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('/<span class="thumb-video">(.*?)</span>/'$match$matches_duration);
                    if (!isset(
$matches_duration['1'])) {
                        
preg_match('/<span class="video" itemprop="duration">(.*?)</span>/'$match$matches_duration);
                    }
                    
                    if (isset(
$matches_duration['1']) && $matches_duration['1']) {
                          
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
                    }
                    
                    
preg_match('/src="(.*?)" thumbs="(.*?)"/'$match$matches_thumb);
                    if (isset(
$matches_thumb['1']) && $matches_thumb['1'] &&
                        isset(
$matches_thumb['2']) && $matches_thumb['2']) {
                        
$thumb_url            $matches_thumb['1'];
                        
$thumb_arr            explode('_'$thumb_url);
                        
$base                $thumb_arr['0'];
                        
$base                substr($base0strrpos($base'/'));
                        
$wh                    $thumb_arr['1'];
                        
$thumbs                explode(';'$matches_thumb['2']);
                        
$video['thumbs']    = array();
                        
                        foreach (
$thumbs as $thumb) {
                              
$video['thumbs'][] = $base.'/'.$thumb.'_'.$wh;
                        }
                    }
                    
                    
$video_arr    explode('/'$video['url']);
                    
$video_id    $video_arr['4'];
                    
                    if (
$video['title'] && $video['duration'] && $video['thumbs']) {
                        
$content $this->clean_html(VCurl::string($video['url'], 'unq=1; interior=1'));
                        
                        
preg_match('/<p id="post-tags">Tags: (.*?)</p>/'$content$matches_tags);
                        if (isset(
$matches_tags['1']) && $matches_tags['1']) {
                            
preg_match_all('/<a href="/tag/(.*?)/" title="(.*?)">(.*?)</a>/'$matches_tags['1'], $matches_tag);
                            
$tags = array();
                            if (isset(
$matches_tag['2']) && $matches_tag['2']) {
                                foreach (
$matches_tag['2'] as $tag) {
                                    
$tags[] = strtolower(prepare_string($tag));
                                }
                                
                                
$video['tags'] = implode(' '$tags);
                            }
                        }
                        
                        
$video['embed'] = '<object type="application/x-shockwave-flash" data="http://www.yobt.com/flash/playeremb2.swf" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'"><param name="movie" value="http://www.yobt.com/flash/playeremb2.swf" /><param name="allowfullscreen" value="true" /><param value="always" name="allowScriptAccess" /><param name="FlashVars" value="xmlfile=http://www.yobt.com/content/'.$video_id.'.xml?embed=true" /></object>';
                        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;
    }
}
Онлайн: 0
Реклама