Hello,
I'm currently developing a media extractor but having some odd problems. The concept is this, the user enters a url into a search form. It then moves onto the next page and stores that url as a variable ($url).
Then the site needs to locate any media (.mp3, mp4, flv) files on that page. So for example. If the user entered http://www.youtube.com/watch?v=i62RiCWxSzs it would provide me with the following :
http://youtube.com/i62RiCWxSzs.flv
http://youtube.com/i62RiCWxSzs_highquality.mp4
Now aswell as displaying this I want it to be links so you see it aswell as being able to click. Its not just for youtube though, I want it to work with facebook, myspace pretty much any site.
I've been using the below code with pretty much 0 success. Can anyone help me or point me in the write direction.
<?
function getlinks($url) {
$data=file_get_contents($url);
preg_match_all('/(href|src)\=(\"|\')[^\"\'\>]+/i',$data,$media);
unset($data);
$data=preg_replace('/(href|src)(\"|\'|\=\"|\=\')(.*)/i',"$3",$media[0]);
return $data;
}
echo "<xmp>";
var_dump(getlinks('$url'));
echo "</xmp>";
?>
Any help greatly appreciated.