nhentai API/site update issue

Starting from around this month, NHViewer seems unusable when accessing the index page.
After some checking, I found that the site has enabled Cloudflare’s ddos protection, showing 2 lines:

1
2
Checking your browser before accessing nhentai.net. This process is automatic.  
Your browser will redirect to your requested content shortly. Please allow up to 5 seconds

Cloudflare ddos protection 5 seconds hints

then redirect to the requested page after ~ 5s.


So… it is more secure I guess? But the problem is that my first HTTP request would receive 503 as the response code, the second HTTP request will be sent programmatically with javascript (that is sent by Cloudflare). My poor API handling just stopped there, came home with the fake 503 Service Unavailable error code.

How to fix?

At the time I was writing (2022-0518), the API has resumed to normal…
So… do I still need to continue developing the solution O_O”

My proposed solution to the issue is to use/rewrite @zhkrb/cloudflare-scrape-Android

I have tested locally that this repo is working, so there should not be a technical bottleneck. Except, I am the bottleneck to work on it. I mean, it is working at this moment :| Maybe next time.

Acknowledgement

Dear Internet, thanks all!!

@zhkrb Java (Android) implementation

@Anorov Python implementation (old)

@scaredos Higher level flow explanation

Java and ScriptEngine

@Rostislav Matl mentioned Selenium solution