Would anyone be able to shed some light on this?
I'm attempting to download video mp4 files from youtube using cURL. I've got the script working so I can download a file from anywhere else, but youtube is just not having it. I've tried setting the user agent and all that malark. Obviously i've got the direct link to the file e.g.Going to that link on my computer allows me to download the video fine, so my guess is that youtube are blocking server downloads somehow..Code:http://www.youtube.com/get_video?video_id=Il1bM6_PWWw&t=vjVQa1PpcFOA2bTs0_IKl-lbhDlaMgcO-B-Ud4KFb2w=&fmt=22
Here's the cURL snippet.
Thanks for any help.PHP Code:ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
$newfile = 'video.mp4';
$file = 'http://www.youtube.com/get_video?video_id=Il1bM6_PWWw&t=vjVQa1PpcFOA2bTs0_IKl-lbhDlaMgcO-B-Ud4KFb2w=&fmt=22';
$fp = fopen (dirname(__FILE__) . '/filedownload/'.$newfile, 'w+');//This is the file where we save the information
$ch = curl_init($file);//Here is the file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
curl_exec($ch);
curl_close($ch);
fclose($fp);
MODs, if this against any rules, remove it. Not really sure tbh.![]()





Reply With Quote



