Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/grab/grabers/madthumbs.php
Строк: 124
<?php
defined
('_VALID') or die('Restriced Acess!');
define('_RESIZE_THUMB', TRUE);
define('_CROP_FROM_SPRITE', TRUE);
define('_CROP_LIMIT', 2300);

class 
VComponent_Admin_grab_madthumbs 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), 'warned=1');
        if (
$html) {
            
preg_match_all('/<li class="thumbbox" (.*?)</li>/', $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'        => 'madthumbs',
                        
'url'        => '',
                        
'title'        => '',
                        
'desc'        => '',
                        
'tags'      => '',
                        
'category'    => '',
                        
'thumbs'    => array(),
                        
'duration'    => 0,
                        
'embed'        => '',
                        
'size'        => 0,
                        
'file_url'    => ''
                    
);
                    
                    
preg_match('/<a href="(.*?)" class="thumb_click"/', $match, $matches_url);
                    if (isset(
$matches_url['1'])) {
                        
$video['url']    = 'http://www.madthumbs.com'.trim($matches_url['1']);
                        
$this->update_progress($progress.'^Processing '.$video['url']);
                        if (
$this->already_added('madthumbs', $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('/<h1 class="mtitle" title="(.*?)">/', $match, $matches_title);
                    if (isset(
$matches_title['1']) && $matches_title['1']) {
                        
$video['title'] = strip_tags(htmlspecialchars($matches_title['1']));
                    }
                    
                    
preg_match('/<span class="al fl">(.*?)</span>/', $match, $matches_duration);
                    if (isset(
$matches_duration['1']) && $matches_duration['1']) {
                          
$video['duration'] = $this->duration_to_seconds($matches_duration['1']);
                    }
                    
                    
preg_match('/longdesc="(.*?)"/', $match, $matches_thumb);
                    if (isset(
$matches_thumb['1']) && $matches_thumb['1']) {
                        
$video['thumbs'] = array($matches_thumb['1']);
                    }
                    
                    
$arr         = explode('/', $video['url']);
                    
$cnt        = count($arr);
                    
$video_id    = $arr[$cnt-1];
                    
                    if (
$video['title'] && $video['duration'] && $video['thumbs'] && $video_id) {
                        
$content    = $this->clean_html(VCurl::string($video['url']), 'warned=1');
                    
                        
preg_match('/<p><strong>Tags:</strong>(.*?)</p>/', $content, $match_tags);
                        if (isset(
$match_tags['1']) && $match_tags['1']) {
                            
preg_match_all('/<a href="(.*?)">(.*?)</a>/', $match_tags['1'], $matches_tags);
                            
$tags = array();
                            if (isset(
$matches_tags['2'])) {
                                foreach (
$matches_tags['2'] as $tag) {
                                    
$tags[] = strtolower(prepare_string($tag));
                                }

                                
$video['tags'] = implode(' ', $tags);
                            }
                        }
                        
$video['embed'] = '<object wmode="transparent" width="'.$this->vcfg['embed_width'].'" height="'.$this->vcfg['embed_height'].'" type="application/x-shockwave-flash" data="http://cache.tgpsitecentral.com/madthumbs/js/flowplayer/flowplayer.embed-3.2.6-dev.swf"><param name="movie" value="http://cache.tgpsitecentral.com/madthumbs/js/flowplayer/flowplayer.embed-3.2.6-dev.swf" /><param value="true" name="allowfullscreen"/><param value="always" name="allowscriptaccess"/><param value="high" name="quality"/><param value="#000000" name="bgcolor"/><param value="config=http://www.madthumbs.com/videos/embed_config?id='.$video_id.'" name="flashvars"/></object>';
                        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;
    }

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