Hi
I am unable to download video file from the YouTube using below script, As per my project requirement i need to download.
I searched in google got below code but that is not working for me, where i got this solution there they were saying that working fine but for me not working.
Can you help me where i did wrong or what is the issue.
In the below code when I reading content using file_get_contents() function i am getting empty value, even i am getting token value.
If i pasted same url in browser which is used in file_get_contents() function getting http 103 status code .
I tried two types
One is:
$url="http://www.youtube.com/watch?v=GeyqwWisSiE";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$info=curl_exec($ch);
curl_close($ch);
preg_match('#"video_id":.*?"(.*?)"#is',$info,$matches);
$video_id=$matches[1];
preg_match('#"t":.*?"(.*?)"#is',$info,$matches);
$tag_t=$matches[1];
debug($tag_t);
$finalUrlVideo = "http://www.youtube.com/get_video.php?video_id=".$video_id."&t=".$tag_t;
$filv = file_get_contents($finalUrlVideo);
Second one is:
$url="http://www.youtube.com/watch?v=GeyqwWisSiE";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$info=curl_exec($ch);
curl_close($ch);
preg_match('#"video_id":.*?"(.*?)"#is',$info,$matches);
$video_id=$matches[1];
preg_match('#"t":.*?"(.*?)"#is',$info,$matches);
$tag_t=$matches[1];
debug($tag_t);
$finalUrlVideo = "http://www.youtube.com/get_video.php?video_id=".$video_id."&t=".$tag_t;
$out = fopen("file.flv","w+");
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $finalUrlVideo);
curl_exec($ch);
curl_close($ch);
Please help me.
Thanking you in advance
Regards
Praveen