Файловый менеджер - Редактировать - /var/www/fetish/scrape/shittytube.php
Назад
<?php include('../core/init.php'); use \fetish\db; set_time_limit(0); $videos = db::query("SELECT * FROM `shittytube` WHERE title IS NULL"); foreach($videos->results() as $video){ scrape_video($video->url_page); } // //foreach (range(1, 660) as $page) { //scrape_list('https://shittytube.com/latest-updates/'.$page, $page); //} //https://shittytube.com/get_file/1/91ef45079ea56ad9757f7a761abe1e0d 777c7bb25b/15000/15505/15505.mp4 //https://shittytube.com/get_file/1/e60dae5f6719971d1eae7a5ab95f0477 777c7bb25b/15000/15505/15505.mp4/ function scrape_list($url, $page) { $html = file_get_contents($url); preg_match_all('/<a href=\"([^\"]*)\" title=\"([^\"]*)\" >/',$html,$matches, PREG_PATTERN_ORDER); foreach($matches[1] as $url){ echo $url."\r\n"; //Insert in the database db::query("INSERT INTO shittytube (url_page, page_count)VALUES(?, ?)", [$url, $page]); } } function scrape_video($url) { $html = file_get_contents($url); preg_match('/videoId: \'(.*?)\'\,/',$html,$videoId); preg_match('/<title>(.*?)<\/title>/',$html,$title); preg_match('/<meta property=\"video:duration\" content=\"(.*?)\"\/>/',$html,$duration); preg_match('/<meta property=\"og:image\" content=\"(.*?)\"\/>/',$html,$thumbnail); db::query("UPDATE shittytube SET title = ?, url_embed = ?, url_thumbnail = ?, duration = ? WHERE url_page = ?",[ $title[1], 'https://shittytube.com/embed/'.$videoId[1], $thumbnail[1], $duration[1], $url ]); } function scrape_index_page($url) { //$html = file_get_contents($url); //preg_match_all('/<a href="(.*?)" title="(.*?)" >/',$html,$matches); //print_r($matches); die(); //Get URL foreach ($matches[1] as $key => $val) { if(!empty($matches[3][$key])){ $id = $matches[1][$key]; $source_uri = $matches[2][$key]; $source = 'http://www.shittytube.com/application/assets/videos/'.$id.'/video.mp4'; $thumb = 'http://www.shittytube.com/application/assets/videos/'.$id.'/preview.jpg'; $title = $matches[3][$key]; //echo $source_uri .'<br>'; //echo $source .'<br>'; //echo $thumb .'<br>'; //echo $title .'<br>'."\r\n"; $uri = rand(1000,9999).'-'.format_uri($title); echo $source.'<br>'; db::query("INSERT INTO videos (title, uri, source_video, source_thumb, source_uri, source, date_fetched)VALUES(?,?,?,?,?,?,?)", [$title,$uri,$source,$thumb,$source_uri,'shittytube',date('Y-m-d H:i:s')]); // Create a stream /*$opts = [ "http" => [ "method" => "GET", "header" => "Accept-language: en\r\n" . "Accept-Encoding: identity;q=1, *;q=0\r\n" . "Referer: ".$source_uri."\r\n" . "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36\r\n" ] ]; $context = stream_context_create($opts); // Open the file using the HTTP headers set above $file = file_get_contents($source, false, $context); //$fileUrl = file_get_contents($source); $fileLocation = 'pee/'.$uri; $s3 = new AWS_S3(); if($s3->putObjectString($file, $_ENV['aws']['bucket'], $fileLocation) ) { //$info = AWS::getObjectInfo(awsBucket, $fileLocation, true); } $source = $_ENV['aws']['cloudfront_url'].$fileLocation; db::query("INSERT INTO videos (title, uri, source_video, source_thumb, source_uri, source, date_fetched)VALUES(?,?,?,?,?,?,?)", [$title,$uri,$source,$thumb,$source_uri,'xpee',date('Y-m-d H:i:s')]);*/ //db::query("INSERT INTO queue (title, uri, source_video, source_thumb, source_uri, source, date_created)VALUES(?,?,?,?,?,?,?)", //[$title,$uri,$source,$thumb,$source_uri,'xpee',date('Y-m-d H:i:s')]); } } } function format_uri( $string, $separator = '-' ) { $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; $special_cases = array( '&' => 'and', "'" => ''); $string = strtolower( trim( $string ) ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); $string = preg_replace("/[^a-z0-9]/u", "$separator", $string); $string = preg_replace("/[$separator]+/u", "$separator", $string); return $string; } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.0.33-0ubuntu0.16.04.16 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка