-
Youtube grabber help
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.
Code:
http://www.youtube.com/get_video?video_id=Il1bM6_PWWw&t=vjVQa1PpcFOA2bTs0_IKl-lbhDlaMgcO-B-Ud4KFb2w=&fmt=22
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..
Here's the cURL snippet.
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);
Thanks for any help.
MODs, if this against any rules, remove it. Not really sure tbh. :)
-
That direct link doesn't work for me, but instead of using curl have you tried using a socket to get the data?
-
Strangely, that link no longer works for me. I'm not sure if the signature part of the URL expires or is unique to an IP address. That would explain the problem i'm getting on the server I guess, I'll try it on localhost to see :)
http://www.youtube.com/get_video?vid...kI2p0c=&fmt=34
Could you let me know if that works for you, as it works for me now.
How would I go about using a socket? Don't recall using one before :P
edit: using localhost works, so i'll just have to generate the direct link on the server for it to work. Hopefully :D
-
those are only for your session on yt maybe ur ip :) Wont work for anyone else :)
Take a look at another download script :)
Lew.