-
-
Notifications
You must be signed in to change notification settings - Fork 499
Implement hCaptcha solving via 2Captcha [URGENT MERGE] #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- implement hCaptcha solving via paid service 2Captcha and browser automation library Playwright with rebrowser-patches - implement sunoApi instances caching so sessions won't be constantly updated - add support for entering cookies not only in SUNO_COOKIE, but also the Cookie HTTP header - update docs and add Russian docs
@gohoski is attempting to deploy a commit to the Linkly AI LLC's projects Team on Vercel. A member of the Team first needs to authorize it. |
Also, this PR imitates requests from the Android app. This way we don't have to solve Cloudflare Turnstile and don't need to constantly update |
also change the Suno interface load trigger from a locator to waitForResponse since the previous locator could not exist on a Suno account without any songs
please note that you can't increase the timeout in any way, even by clicking,so the only option we have is to just reinstate the solving process
I tried this PR on my own 2 days ago (with the help of Gohoski) and it's working great. |
If you have any problems with this PR, you can say them here or DM me via Discord/Telegram in my bio. |
I occasionally ( Every 2/3 generations) get a unhandled TimeoutError caused by " await page.waitForResponse('https://img**.hcaptcha.com/**', { timeout: 60000 }); // wait for hCaptcha image to load" |
@angejr can you try with BROWSER_HEADLESS=false and see how the hCaptcha window looks? Maybe it's a new hCaptcha type |
Somehow removing headless makes it work, thanks ! |
- fixed bug in dragging type of hCaptcha when worker did not select an even amount of coordinates and it would crash - change waitForResponse function to a waitForRequests util function with more proper checks
@angejr try it now with headless mode, I tried to change the waitForRequests logic |
@gohoski I've done some work on getting the branch to work in Docker. I tried getting it to work with Alpine, as this is the base in the current Dockerfile, but without success. It works headless with Debian Bookworm base, and Microsoft's official Playwright base image that's based on Ubuntu. In all cases I cannot get non-headless mode to work under Docker. I'll summarize what I needed to do: Change
Change
|
@gohoski: thank you for your contribution ❤️. After fixing some lock file issues with Vercel, I get the following error when executing an API call:
Is there a way to tell Vercel it needs playwright installed? |
@jonico I don't use Vercel, but I guess it uses Docker. I had to use a different Dockerfile because I had the same issue:
I also had to change
This was the only way I could get Docker to work. Maybe this is of use for Vercel. FWIW I also changed
|
…ead of a manual command, fix Docker & add notice about macOS recommendation
Updated Docker (thanks to @hedleyroos!) in my new commit and added a cookie check, so unnecessary cookies from some browsers won't be considered as a full SUNO_COOKIE. Please test this and LMK. Interestingly, I discovered that you can actually use a macOS system to vastly improve performance and to avoid CAPTCHAs. This is because it is an unpopular platform for web-scraping, especially when you put it next to Linux & Windows. Also put that in the README. Better not let Ace Data Cloud to know about this xD Also, I made it so the browser would be installed automatically on |
@gohoski thank you for your efforts 🎉 - unfortunately, same issue in Vercel (no chromium browser found), as the runtime environment (serverless) is different from the build environment (where chromium gets installed) |
@jonico Try to If it still doesn't work, we will have to unfortunately discontinue using Vercel. I have also heard that it has a 60s limit on each request, which is no bueno for suno-api. Maybe we can develop a job/task queue system for these cases, but first we will need to discuss is Vercel even a good host for these projects. |
Don't give up, it's a great PR. I actually have a working chromium vercel deployment for another app I made for scraping substack posts on the edge using playwright , I will bring that over and share my solution once I have it working |
@gohoski I am now getting a new error message:
Looks as if the approach may work in general.
You can change the max timeout of Vercel in the free tier to 60 seconds (see #86 ) and up to 900 seconds in the paid plans. |
Thank you for your work. I will merge it as soon as possible. |
Fixed in #227 |
This PR finally implements hCaptcha solving via paid service 2Captcha and browser automation library Playwright with rebrowser-patches. If the CAPTCHA verification is needed by Suno, it automatically spawns a browser, goes to suno.com/create, solves the CAPTCHA and gets the hCaptcha token. No any 'fake app' songs have ever been generated in my tests.
Unfortunately, no free solutions to this problem exist. While this solution is resource-intensive, could take a really long time (from 100s to 500s, depends on the worker that solves the CAPTCHA) and not free, it actually works and you don't actually have to pay much. hCaptcha tokens also last anything from 20 mins up to 2 hours, so if you have a Suno account with a subscription that enhances the limits, you won't have to solve CAPTCHAs that much if you're lucky enough to get a 2-hours hCaptcha token.
Besides that, this PR:
SUNO_COOKIE
, but also in theCookie
HTTP header, which can really be useful for using multiple accountsHowever, before merging this PR, I highly recommend you to test it. Suno and hCaptcha can change something in their CAPTCHA really soon and this code could not work. But, with the current solution, the possibility of that happening is still low.
I would also like to ask @blueeon to remove the Chinese paid Suno API implementations spam in the Issues tab. It is really annoying and not helping the current situation.
Also, maybe you could create a Discord server or a Telegram group-chat for suno-api, so we would get notified about problems more fast and just talk about Suno things. It would be a very useful addition, especially when Suno is constantly taking down external APIs.
Fixes #220, fix #215, fix #206, fix #205, fix #204, fix #200, fix #198, fix #195 (now that's a LOT of issues)