Ok, well, it's not complete as such, but all it needs is the code to copy the video or force download headers, etc... It gets the video url, etc, just needs the last step coding, n I'm over it for now, lol...
hope someone can finish this code n make a dwnload.php file or whatever, then you got a youtube grabber running straight off youtube
PHP Code:
<HTML>
<HEAD>
<TITLE>YouTube Grabber</TITLE>
</HEAD>
<BODY>
<?php
function fwrite_stream($fp, $string) {
for ($written = 0; $written < strlen($string); $written += $fwrite) {
$fwrite = fwrite($fp, substr($string, $written));
if ($fwrite === false) {
return $written;
}
}
return $written;
}
if (isset($_GET['furl']))
{
//this bit needs fixing...
//
$url = $_GET['furl'];
$tit = $_GET['tit'];
$file = $tit;
//not working...
$current = file_get_contents($url);
$fp = fopen($file, 'w');
fwrite_stream($fp, $current);
fclose($fp);
}
if (isset($_GET['vid']))
{
$vid = $_GET['vid'];
}
else
{
$vid = "8V8FIEDGo2k";
}
$data = file_get_contents("http://gdata.youtube.com/feeds/mobile/videos/$vid");
preg_match_all("/<media:content url='(.*)'/i", $data, $a);
preg_match_all("/<title type='text'>(.*)/i", $data, $title);
$count = count($a[1]);
$titles = count($title[1]);
echo "<b>Number of Urls</b> = " .$count."<p>";
for ($row = 0; $row < $count ; $row++)
{
$data1 = $a[1]["$row"];
$url = str_replace("' type='video/3gpp' medium='video' isDefault='true' expression='full'", "", $data1);
$url = str_replace(" yt:format='1'/>", "", $url);
$url = explode(" ", $url);
$url = $url[0];
$tit = $title[1]["0"];
$tit1 = str_replace("</title>", "", $tit);
$tit = explode("<con", $tit1);
$tit1 = $tit[0];
$tit = str_replace(" ", "_", $tit1);
$tit = str_replace(":", "", $tit);
$tit = str_replace("'", "", $tit);
$tit = str_replace("(", "", $tit);
$tit = str_replace(")", "", $tit);
$tit = str_replace('"', "", $tit);
echo "Title: ".$tit1."<br/><img src=\"http://img.youtube.com/vi/".$vid."/default.jpg\" /><br>";
echo "<a href=\"$url\">Click To Watch</a><br/><a href=\"?furl=$url&tit=$tit.3gp\">Click To Download</a> - Not Working<hr>";
}
echo "Enter Youtube Video ID:<br/>ie:http://www.youtube.com/watch?v=<b><i>8V8FIEDGo2k</i></b><br/>The highlighted bit in the url above...<br/>";
echo "<form action='index.php' method='GET'><input type='text' name='vid'><br/><input type='submit' value='Get Video'><br/></form>";
?>
</BODY>
</HTML>
Comment