<?php
 ob_start();
 include("includes/ayar.php");
$videoid=$_GET["k"];
//$format = $_GET["fmt"];
if(empty($format)) $format = 18;
$content= DosyaAl("http://www.youtube.com/get_video_info?video_id=$videoid");
parse_str($content);
$url = "http://www.youtube.com/get_video.php?video_id=".$videoid . "&t=".$token."&fmt=".$format;
$headers = get_http_header($url);

foreach($headers as $h){
if(strpos($h,"googlevideo.com")!=false){
$url = substr($h,10);
break;
}
}
echo $url;
header("Location: $url");
ob_end_flush();
?>
12inci satır
foreach($headers as $h){
victories yazdığı cevapta $headers = get_header($url); satırındaki get_headers().. fonksiyonu bende çalışmadı içinde şöyle bir yapı kullandımm..
$headers = get_http_header($url)
get_http_header fonksiyonuda
function get_http_header( $url ){
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_HEADER, 1 );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch, CURLOPT_NOBODY, 1 );
    $ret = curl_exec( $ch );
    curl_close( $ch );
    return $ret;
}
şeklinde yaptımm..

header("Location: $url");
satırındada şöyle bir hata var.
Warning: Cannot modify header information - headers already sent by (output started at /home/yyyy/xxx.com/ttvideo.php:1) in /home/yyyy/xxx.com/ttvideo.php on line 19
kullandığım host dreamhost....