wonko
04-15-2008, 09:02 AM
I'm trying to make a script where someone can enter the URL of a youtube video, and it puts out a donwload link to the .flv that the user can then download. I've been scouring the internet and I can't find a tutorial or anything, but I did manage to write this code which doesn't ouput anything for some reason:
<?php
$txt = file_get_contents('http://www.youtube.com/watch?v=i0TXut4Oc2g');
preg_match('/video_id:\'[\w]{11}\'/', $txt, $video_id_temp);
preg_match('/[\w]{11}/',$video_id_temp[0],$video_id_temp2);
$video_id = $video_id_temp2[0];
preg_match('/l:\'[\d]{1,15}\'/',$txt,$l_temp);
preg_match('/[\d]{1,15}/',$l_temp[0],$l_temp2);
$l = $l_temp2[0];
preg_match('/t:\'[\w]{32}\'/',$txt,$t_temp);
preg_match('/[\w]{32}/',$t_temp[0],$t_temp2);
$t = $t_temp2[0];
$test="&l=".$l;
$test2="&t=".$t;
$url="http://youtube.com/get_video.php?video_id=";
print "<td><tr><a href='".$url.$video_id.$test.$test2."'> Download it!</a></td></tr>";
?>
anyone know what's wrong? Also if anyone knows a site they can direct me to that'd be awesome
<?php
$txt = file_get_contents('http://www.youtube.com/watch?v=i0TXut4Oc2g');
preg_match('/video_id:\'[\w]{11}\'/', $txt, $video_id_temp);
preg_match('/[\w]{11}/',$video_id_temp[0],$video_id_temp2);
$video_id = $video_id_temp2[0];
preg_match('/l:\'[\d]{1,15}\'/',$txt,$l_temp);
preg_match('/[\d]{1,15}/',$l_temp[0],$l_temp2);
$l = $l_temp2[0];
preg_match('/t:\'[\w]{32}\'/',$txt,$t_temp);
preg_match('/[\w]{32}/',$t_temp[0],$t_temp2);
$t = $t_temp2[0];
$test="&l=".$l;
$test2="&t=".$t;
$url="http://youtube.com/get_video.php?video_id=";
print "<td><tr><a href='".$url.$video_id.$test.$test2."'> Download it!</a></td></tr>";
?>
anyone know what's wrong? Also if anyone knows a site they can direct me to that'd be awesome