Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by YUNUS O. ( 14 years ago )
<?php
set_time_limit(0);
function source($vid){
    $ch = curl_init();
 curl_setopt($ch , CURLOPT_URL , 'http://www.youtube.com/watch?v='.$vid);
 curl_setopt($ch , CURLOPT_RETURNTRANSFER , TRUE);
 curl_setopt($ch , CURLOPT_COOKIEFILE , dirname(__FILE__) . '/cookie.txt');
 curl_setopt($ch , CURLOPT_COOKIEJAR , dirname(__FILE__) . '/cookie.txt');
 curl_setopt($ch , CURLOPT_USERAGENT , 'Firefox / 2.0.16');
 curl_setopt($ch , CURLOPT_REFERER , 'http://www.youtube.com/watch?v=' . $vid);
 $source =  curl_exec&#40;$ch&#41;;
 curl_close($ch);
    
    return $source;
}

function downloadurl($source){
 preg_match('/url_encoded_fmt_stream_map(.*?)\;/',$source,$preg);
 $fmtmap = urldecode(urldecode(urldecode($preg[1])));
 $fmtmaps = explode('url=',$fmtmap);
 for($i = 0 , $c = count($fmtmaps) ; $i < $c ; $i++ )
 {
  if(
   strpos($fmtmaps[$i],'quality=medium') !== FALSE &&
   strpos($fmtmaps[$i],'video/x-flv') !== FALSE
  )
  {
   $fmt = $fmtmaps[$i];
  }
 }
 $fmt = explode('&fallback;_host',$fmt);
 return $fmt[0];
}


function download($headers , $fileLocation, $fmturl){
        
        if(array_key_exists('Location',$headers))
  {
   $url = parse_url($headers['Location']);
   $dl = $headers['Location'];
  }
  else
  {
   $dl = $fmturl;
   $url = parse_url($fmturl);
  }
  $fp = fopen&#40;$fileLocation , 'w+'&#41;;
  $ch = curl_init();
  curl_setopt($ch , CURLOPT_URL , $dl);
  curl_setopt($ch , CURLOPT_RETURNTRANSFER , TRUE);
  curl_setopt($ch , CURLOPT_COOKIEFILE ,  dirname(__FILE__) . '/cookie.txt');
  curl_setopt($ch , CURLOPT_COOKIEJAR , dirname(__FILE__) . '/cookie.txt');
  curl_setopt($ch , CURLOPT_USERAGENT , 'Firefox / 2.0.16');
  curl_setopt($ch , CURLOPT_REFERER , 'http://www.google.com/');
  curl_setopt($ch , CURLOPT_FILE , $fp);
  curl_exec&#40;$ch&#41;;
  curl_close($ch);
  fclose($fp);   
}

function cname($name){
 $trk = array('ı','ğ','ü','ş','ö','ç','Ğ','Ü','Ş','İ','Ö','Ç',' ');
 $eng = array('i','g','u','s','o','c','g','u','s','i','o','c','-');
 $new = str_replace($trk,$eng,$name);
 $new = preg_replace('/[^0-9A-Za-z-]/','',$new);
 $new = preg_replace('/\-+/','-',$new);
 $new = strtolower($new);
 return $new;
}





    $url = 'http://thenewboston.org/';
    $watch = 'watch.php?cat=6&number;=';
    $youtube = 'http://www.youtube.com/watch?w=';
    $content = file_get_contents&#40;$url . 'list.php?cat=6'&#41;;
    preg_match_all('/href=\"watch.php\?cat=6\&number;=(.*?)\"/si',$content,$urls);
    
    for($i = 0 ; $i < count($urls[1]); $i++){
        $video = file_get_contents&#40;$url . $watch . $urls[1][$i]&#41;;
        $video = explode('<a href="http://www.youtube.com/watch?v=',$video);
        $video = explode('">Click here to watch this video on YouTube',$video[1]);
        $videoID = $video[0];
        $source = source($videoID);
        $downloadURL = downloadurl($source);
        $headers = get_headers($downloadURL);
        $title = explode('<title>',$source);
        $title = explode('</title>',$title[1]);
        $title = $title[0];
        download($headers,dirname(__FILE__)  . '/video/' . cname($title) . '.flv',$downloadURL);
    }
?>

 

Revise this Paste

Your Name: Code Language: