Hello,
I’m working on a PHP script that used to grap videos from youtube. It was working properly until the new update of YouTube. I tried to figure out the problem and make the suitable change in the code in order to make it compatible with the new YouTube website. The video page on youtube still has the parameter fmt_url_map which carry the URLs of the FLV files of the video in different quality.
The script decodes these URLs and print them. On my localhost I can use the URLs to download but when the script runs on my website, youtube gives me “Forbidden 403 error” when I click the URLs (ex: http://v19.lscache3.c.youtube.com/videoplayback?ip=69.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&algorithm=throttle-factor&itag=5&ipbits=8&burst=40&sver=3&expire=1271818800&key=yt1&signature=382C925AD4C58505630AE3362DA9D664EF197BB3.85F626C59CB659D32DC8275873962996153CC0F8&factor=1.25&id=b4eb51328b994799)
This is my PHP code:
$youTubeFile = file_get_contents($_POST[youtubevideolink]);
preg_match('/&fmt_url_map=(.*?)&/', $youTubeFile, $match);
$urls = urldecode($match[1]);
$urls = explode(",", $urls);
foreach($urls AS $url)
{
$explode = explode("|", $url);
echo "$explode[0] : <a href='$explode[1]'>".$explode[1]."</a><hr>";
}
I have these questions:
1- I read that YouTube consider downloading their videos is a violation of their terms of use but Iam not sure about that. If so, why do they allow RealPlayer and the other Windows applications to download their videos? Also, why do they leave the fmt_url_map parameter on the video page source?
2- I noticed that most of the websites that allow you to download from youtube stopped working but I found this website http://www.youtubeto3gp.com/ which states that they made an upgrade to make their website compatible with the new YouTube which means that the upgrade is possible. Any help on how to fix my code to meet the new update?
Thanks in advance.