Handle youtube CAPTCHAs (402 errors) gracefully · Issue #154 · ytdl-org/youtube-dl (original) (raw)

I don't really think this is the place to expand much on my comments above.

Whilst I hoped to help people who are encountering this problem, this is a bug report for youtube-dl, not a homework assistance forum.

Once the user fills in a captcha, the IP address is once again allowed to download.

However, filling in a captcha sets a cookie in the browser - this session is given freer access to YouTube than other sessions from the same IP.

Even with another session allowed access, it is easy for youtube-dl to once again exceed permitted downloads (and once again hit the 402 error).

youtube-dl does not have any way to tell you what captcha it wants you to solve, thus also no way for you to return the result of a captcha.

If you can have your PHP program flush the cookies from a browser and open a new browser on the same machine, then that will work.

The easiest way I have found to solve this is to build a dynamic delay - when you get a 402 error, just wait for some time before trying again. When you get multiple successful downloads, decrease the delay. This means the downloads are slower, but no human interaction is required. If you fill in a captcha, then you'll need to fill in another one within a couple of downloads; if you just wait some time (or take it easy for some time) then you can eventually resume again at a reasonable speed.

I am not going to tell you any more of what I know of the parameters of YouTube's rate limiting. As soon as they become publicly disseminated, YouTube will tighten their restrictions further.

I repeat: THIS IS A BUG REPORT, NOT A HELP FORUM.
If you need further assistance, post a question in an appropriate forum and message or email me, so that I can answer it there in public.