Closed Ducote closed 2 years ago
The example provided in readme works for me (I've made clean container with sudo docker run -it --rm node:slim /bin/bash
).
Could you provide a minimal working example with such error?
I identified that the problem come from a specific manga : #374874
If this manga shows up, it broke the search.
The error shows up with this code for me : (updated npm and dependencies yesterday)
const { API, } = require('nhentai-api');
const nhentai = new API();
var recherche = '"SeFri+Ijou"+"Konyakusha+Miman"+"More+Than+A+Sex+Friend"+"Less+Than+A+Fiancée"';
nhentai.search(recherche).then(async search => {
if (search.books.length == 0){
console.log('Nothing');
}
else{
console.log('Something');
}
});
The other thing that tickles is me is that when I use THIS specific research, it gives a code 403. But the search my bot use gives a 404 :
var recherche = "english+<a bunch of removed tags>+pages%3A>15+uploaded%3A>24h";
I can confirm this behavior.
Locally I've tested connecting through proxies and requesting target url with curl.
Looks like some sort of filtering by user agent.
I'll investigate this tomorrow.
If you have spare time, you can try to compile master branch with different user agent and test if that works.
User agent is setting here: https://github.com/Zekfad/nhentai-api/blob/5f638265d5aab7035654fcbbb68948493435bddb/src/api.js#L149
The endpoint that fails is /api/galleries/search?query=%22SeFri+Ijou%22+%22Konyakusha+Miman%22+%22More+Than+A+Sex+Friend%22+%22Less+Than+A+Fiancée%22&page=1
, you can also experiment with curl and headers to test that.
I've investigated the issue. Turns out that I pass search string as is to query (I remember that I had a reason for that).
To fix your case, simply wrap your query with encodeURIComponent
like follows:
- var recherche = '"SeFri+Ijou"+"Konyakusha+Miman"+"More+Than+A+Sex+Friend"+"Less+Than+A+Fiancée"';
+ var recherche = encodeURIComponent('"SeFri+Ijou"+"Konyakusha+Miman"+"More+Than+A+Sex+Friend"+"Less+Than+A+Fiancée"');
Hello
08/29/2019 : 11PM UTC +2 Works flawlessly
09/29/2019 : 11PM UTC +2 Having an error
Nota Bene : the ^ is set under the on.
Strangely, the website works flawlessly with my browser and because on TLS, I'm not able to see much with a DPI. Just seing that the DNS response is correct (104.27.194.88 and 104.27.195.88).
Thanks for your hardwork, You're breathtaking !