Youtube Grabber (almost)

Started on the old forum in July 2013 · view the original in the archive · old links redirect here

6 replies · 1,167 views · started 13 years ago · 1 min read

4 participants
pmbguy Senior · 344 posts #1

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...

<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>

hope someone can finish this code n make a dwnload.php file or whatever, then you got a youtube grabber running straight off youtube 🙂

chelios Junior · 13 posts #2

you know that youtube will change api and stuff again and again all grabers wont work ,again..

charith7788 Developer · 51 posts #4

this method won't work again now youtube working on youtube 2.0 & 3.0, old v 1.0 is getting shut

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close