<?php
error_reporting(0);
/*
@author: huyphungvan
@date: 10:30 AM 8/23/2009
@customer: diendantiengiang.com
*/
function downloadFLV($vid = ‘5-d2eZrDcns’) {
if (empty($vid)) return false;
$url = ‘http://www.youtube.com/get_video_info?&video_id=’ . $vid;
$source = file_get_contents($url);
$source = urldecode(urldecode($source));
$head = strpos($source, “|”);
if ($head === false) return false;
$tail = strpos($source, “|”, $head + 1);
if ($tail === false) return false;
$flv = substr($source, $head + 1, $tail – $head);
$pos = strrpos($flv, “,”);
$flv = substr($flv, 0, $pos);
// echo $source;
// echo “<hr />”;
return $flv;
}
// URL: /download.php/9_AoAgrgZ70
$vid = $_SERVER[“PATH_INFO”];
$vid = substr($vid, 1);
$flv = downloadFLV($vid);
if (!empty($flv)) header(“Location: $flv”);
else {
header(“HTTP/1.0 404 Not Found”);
echo ‘File not found’;
}
?>