<?php
/** Configuration
*/
$cache_url = 'cache.xml'; //Cache URL
$cache_time = 30; //If empty, no Cache
$video_id = $_GET['v'];
/**
*/
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id={$video_id}"),$i);
if($i['status'] == 'fail' && $i['errorcode'] != '150') die(header("Location: errors/error01.mp4")); //Error
if($i['status'] == 'fail') { //Error code is 150
//Cache File (suggestion from @burkul)
if(!isset($cache_url)) $cache_url = "cache.xml";
$cache = file_get_contents($cache_url);
if( time() - $cache < $cache_time && isset($cache_time)) die(header("Location: errors/error02.mp4"));
$cache = fopen($cache_url, "w");
fwrite($cache, time());
fclose($cache);
//
$content = file_get_contents("http://www.youtube.com/watch?v={$video_id}");
preg_match_all ("/(\\{.*?\\})/is", $content, $matches);
$obj = json_decode($matches[0][1]);
$token = $obj->{'t'}; $fmt_map = $obj->{'fmt_map'}; $fmt_url_map = $obj->{'fmt_url_map'};
}
else { //No error code
$token = $i['token']; $fmt_map = $i['fmt_map']; $fmt_url_map = $i['fmt_url_map'];
}
//Video Format
if(!isset($fmt_map)) die(header("Location: errors/error03.mp4"));
preg_match_all ("/(.*?),/is", $fmt_map, $fmt_map);
foreach( $fmt_map[1] as $fmt_i => $fmt_value){
$fmt_value = explode('/',$fmt_value);
if ($fmt_value[0] == 6) {$fmt = 6;} else{$fmt = 5;} //Highest .MP4 Format
}
$url = "http://www.youtube.com/get_video.php?video_id={$video_id}&vq=2&fmt={$fmt}&t={$token}";
$headers = get_headers($url,1);
$video = $headers['Location'];
if(!isset($video)) {
$fmt_url_map = explode(',',$fmt_url_map);
foreach( $fmt_url_map as $fmt_i => $fmt_url){
$fmt_url = explode('|',$fmt_url);
if($fmt_url[0] == 6 || $fmt_url[0] == 5) $video = $fmt_url[1]; break;
}
}
if(!isset($video)) die(header("Location: errors/error01.mp4"));
is_array($video) ? $video = $video[0] : $video = $video;
header("Location: $video"); //Return Video
?>Youtube videolarını bu script sayesinde istediğiniz formatta indirtebilirsiniz. Türkçe bir çok kaynakta aramama rağmen çalışanını bulamamıştım. En sonunda yabancı bir forumda bulup lâzım olur diye arşivime atmıştım. Şimdi denk gelince sizlerle paylaşmak istedim. Çalıştıramayan yada anlamayan olursa konu altında yardımcı olmaya çalışırım.Ayrıca indirtmek yerine playerınızda dinlettirmeyi/oynatmayı da tercih edebilirsiniz. Ah şu youtube videolarının logosuz ve yalın hâlini bir alabilseydim dediğiniz işi yapan script diye açıklayayım kısaca.
Download : Tıklayın