View Single Post
Old 10-06-2012, 11:13 PM   PM User | #502
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by atanas View Post
New problem. I think that if i download too many videos from youtube, it active a protect.

Sorry for the interruption. We have been receiving a large volume of requests from your network. To continue with your YouTube experience, please enter the verification code below

When i try open video from the server I am redirected to this page: http://www.youtube.com/das_captcha?next=/


How to overcome that protect ?

Thanks !
This is the second time someone has reported this problem, and I'm now officially convinced that this is an issue worth addressing. I also have a good idea of how to fix this. So, the next time I release a new version of the software, you can expect that I will do exactly that.

In the meantime, how many requests to YouTube are you making to get that CAPTCHA? Thousands? Tens of thousands? More? And in what time frame? Per day? Per hour? Some other duration?

Per a previous, quick brainstorming session about this very issue, I came up with the following plan to combat this CAPTCHA:

Quote:
1) In YouTubeToMp3Converter:ownloadVideo, replace file_get_contents with cURL request to video URL (enable cookies/"keep-alive" for the curl session)
2) return HTML source of cURL request to PHP variable (DO NOT close cURL connection)
3) If captcha image is found in html source, continue to step #4. Otherwise stop and proceed with conversion script normally.
4) print and flush new markup to page that creates a modal window (on top of existing content) displaying captcha image ripped from HTMl in PHP variable. Include a text field in modal window for user to type captcha phrase. Include a submit button. When the submit button is pressed (input type = button), after user types code, have the button trigger some AJAx that sends the user's unique id and typed captcha phrase to PHP script on server. The PHP script receives this data and adds a node to an XML file on the server. Also, after button is pressed, a message displays inside modal window that says the form is processing and to please wait.
5) In the meantime, directly after the print and flush of markup at the begining of step #4, initiate a while loop that checks the XML file for the user's unique ID and captcha phrase. If a matching XML node is not found, the script sleeps for X number of seconds, and then tries again. This loop continues until the node is found or some arbitrary time limit is reached.
6) When and if the XML node is found, more markup is printed and flushed that removes the modal window. Using the original, open cURL handle, send a subsequent request to the page that the YouTube captcha form submits to, sending corresponding user provided captcha phrase found in XML as POST variable. Go to step #1.
7) If the XML node is not found after time limit expires, more markup is printed and flushed that removes the modal window. the original conversion form submits, and an error message tells user that he/she took too long to enter the captcha, and to please try the conversion again (and, that, of course, the conversion failed).
Again, this is a very rough approach to how I might handle the issue. You are free to try to implement this approach yourself, or implement some other approach, until I have a chance to address the issue in the next version of the app.
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote