phpnewbie8 Posted April 2, 2010 Share Posted April 2, 2010 I have a website that allows users to enter a youtube video and it serves the flv video file. It has recently stopped working because youtube changed their code. I am having trouble figuring out how to fix it. The problem is, if you try to use the url that provides the video file, you get a forbidden page. The only way I can get it to work is if I go to the youtube video, load it up, then open a new tab, CLOSE the video tab, then paste the special URL. So basically, it will only give the file if it is not already being streamed, and there is some history that you were actually on the page. If I do this through PHP, it knows I am not requesting it from their page so it forbids the request. I know it is possible to get around this, but not sure if it is possible with only php. I have found one website (savevid.com) that uses a java applet to somehow do it. Is there some way I can make my php code mimic a regular youtube user, or some other workaround for this? An example: Youtube video: Direct Video File: http://v10.lscache7.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dWRVJMVF9FSkNNNl9KRlhJ&algorithm=throttle-factor&itag=34&ipbits=0&burst=40&sver=3&expire=1270216800&key=yt1&signature=C748A7F0639B07870EBB6FD32817FBF46A26B72B.8BBBE1D435E55DAAF3A9335AF7AD088CCC04C804&factor=1.25&id=c53ab3e9af8f0395& I have tried to manually change these fields (like ip, expire) but it doesn't seem to matter. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/197330-extracting-youtube-flvmp4/ Share on other sites More sharing options...
dreamwest Posted April 2, 2010 Share Posted April 2, 2010 curl headers will do it: curl_setopt($ch, CURLOPT_HEADER, true); echo out the header redirects to find the flv location Quote Link to comment https://forums.phpfreaks.com/topic/197330-extracting-youtube-flvmp4/#findComment-1035857 Share on other sites More sharing options...
phpnewbie8 Posted April 2, 2010 Author Share Posted April 2, 2010 curl headers will do it: curl_setopt($ch, CURLOPT_HEADER, true); echo out the header redirects to find the flv location Thanks for the reply. I might be doing something wrong, but it appears to be giving the same forbidden message using curl. For example if I use this sample code I found: <?php // create a new curl resource $ch = curl_init(); $link = "http://v9.lscache5.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dWRVJPU19FSkNNNl9KSVdH&algorithm=throttle-factor&itag=5&ipbits=0&burst=40&sver=3&expire=1270245600&key=yt1&signature=964EC10D71B272A2714B8B1C30A55739BA05826A.994F742EC48E3834188B06CF9479F3A562E57924&factor=1.25&id=48166e1cb03d2a8b"; // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $link); curl_setopt($ch, CURLOPT_HEADER, 1); // grab URL and pass it to the browser curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); ?> The browser shows "HTTP/1.1 403 Forbidden Content-Type: text/plain Connection: close Date: Fri, 02 Apr 2010 16:07:40 GMT Server: gvs 1.0." Which is the same thing I see if I run my other code and look in firebug. I was thinking I could modify the headers I send to youtube, but looking in firebug my header matches the request youtube has on their own page. This one is very strange to me. Like I said before, someone is doing it using a java applet. Is it possible there are things you can do in a java applet that are not possible in php? Like somehow open a browser inside of it? I am just trying to narrow down what method they are using... Quote Link to comment https://forums.phpfreaks.com/topic/197330-extracting-youtube-flvmp4/#findComment-1035968 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.