Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/xvideos.php
Строк: 102
<?php
defined
('_VALID') or die('Restriced Acess!');
define('_RESIZE_THUMB'TRUE);
class 
VComponent_Admin_grab_xvideos 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 width="183">(.*?)</td>/'$html$matches);
            if (empty(
$matches['1'])) {
                
preg_match_all('/<div class="thumbBlock"(.*?)</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) {
                    
$match preg_replace('/<script>(.*?)</script>/'''$match);
                    
                    ++
$count;
                    if (
$count $this->overflow) {
                        
$this->errors[]    = 'Overflow reached (500)! Aborting!';
                        return 
FALSE;
                    }
                    
                    
$video    = array(
                        
'site'        => 'xvideos',
                        
'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'])) {
                        
$video['url']    = 'http://www.xvideos.com'.trim($matches_url['1']);
                        
$video['title']    = strip_tags(trim($matches_url['2']));
                        
$this->update_progress($progress.'^Processing '.$video['url']);
                        if (
$this->already_added('xvideos'$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="duration">((.*?))</span>/'$match$matches_duration);
                      if (isset(
$matches_duration['1'])) {
                          
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
                      }
                    
                    
preg_match('/<img src="(.*?)" id/'$match$matches_thumb);
                    if (isset(
$matches_thumb['1'])) {
                        
$thumb_url       $matches_thumb['1'];
                        
$thumb_url       str_replace('.jpg'''$thumb_url);
                        
$thumb_url       substr($thumb_url0strrpos($thumb_url'.'));
                        
$video['thumbs'] = array(
                            
$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',
                            
$thumb_url.'.12.jpg',
                            
$thumb_url.'.13.jpg',
                            
$thumb_url.'.14.jpg',
                            
$thumb_url.'.15.jpg',
                            
$thumb_url.'.16.jpg',
                            
$thumb_url.'.17.jpg',
                            
$thumb_url.'.18.jpg',
                            
$thumb_url.'.19.jpg',
                            
$thumb_url.'.20.jpg',
                            
$thumb_url.'.21.jpg',
                            
$thumb_url.'.22.jpg',
                            
$thumb_url.'.23.jpg',
                            
$thumb_url.'.24.jpg',
                            
$thumb_url.'.25.jpg',
                            
$thumb_url.'.26.jpg',
                            
$thumb_url.'.27.jpg',
                            
$thumb_url.'.28.jpg',
                            
$thumb_url.'.29.jpg',
                            
$thumb_url.'.30.jpg'
                        
);
                    }
                    
                    
$video_id   str_replace('http://www.xvideos.com/video'''$video['url']);
            
$video_id    str_replace('/video'''$video_id);
                    
$video_id   explode('/'$video_id);
                    
$video_id   $video_id['0'];
                    if (
$video['duration'] && $video['thumbs'] && isset($video_id)) {
                        
$content $this->clean_html(VCurl::string('http://www.xvideos.com'.$video['url']));

                        
preg_match('/<ul id="video-tags">(.*?)</ul>/'$content$matches_tags);
                        if (isset(
$matches_tags['1'])) {
                                            
preg_match_all('/<a href="/tags/(.*?)">(.*?)</a>/'$matches_tags['1'], $matches_tag);
                                            
$tags   = array();
                                            if (isset(
$matches_tag['1'])) {
                                                foreach (
$matches_tag['1'] as $tag) {
                                                        
$tags[] = strtolower(prepare_string($tag));
                                                }
                    
                                                
$video['tags'] = implode(' '$tags);
                                            }
                                    }    


                        
$video['embed'] = '<iframe src="http://flashservice.xvideos.com/embedframe/'.$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;
    }

}
Онлайн: 0
Реклама