diff --git a/package.json b/package.json index a583d9c..c9edefa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jandapress", - "version": "2.1.6-alpha", + "version": "2.1.7-alpha", "description": "RESTful and experimental API for the Doujinshi, Pressing the whole nhentai, pururin, hentaifox, and more.. where the official one is lack.", "main": "build/src/index.js", "scripts": { diff --git a/src/utils/modifier.ts b/src/utils/modifier.ts index 3886b55..3ec2b5f 100644 --- a/src/utils/modifier.ts +++ b/src/utils/modifier.ts @@ -171,7 +171,7 @@ export function maybeError(success: boolean, message: string) { */ export function nhentaiStrategy() { let strategy: string; - if (process.env.NHENTAI_IP_ORIGIN === "true" || process.env.NHENTAI_IP_ORIGIN === undefined) strategy = c.NHENTAI_IP_3; + if (process.env.NHENTAI_IP_ORIGIN === "true" || process.env.NHENTAI_IP_ORIGIN === undefined) strategy = c.NHENTAI_IP_4; else strategy = c.NHENTAI; return strategy; } diff --git a/src/utils/options.ts b/src/utils/options.ts index 44814e0..6645009 100644 --- a/src/utils/options.ts +++ b/src/utils/options.ts @@ -8,6 +8,7 @@ export default { NHENTAI_IP: "http://35.186.156.165", NHENTAI_IP_2: "http://173.82.30.99:3002", NHENTAI_IP_3: "http://138.2.77.198:3002", + NHENTAI_IP_4: "http://129.150.63.211:3002", ASMHENTAI: "https://asmhentai.com", THREEHENTAI: "http://3hentai.net" }; \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 1733e9e..0d4be1a 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,15 +1,32 @@ import c from "../src/utils/options"; import p from "phin"; +import { name, version } from "../package.json"; -for (const url of - [c.HENTAIFOX, c.PURURIN, c.HENTAI2READ, c.SIMPLY_HENTAI, - c.SIMPLY_HENTAI_PROXIFIED, c.NHENTAI, c.NHENTAI_IP_3, c.ASMHENTAI]) { - p({ url }).then(res => { - if (res.statusCode !== 200) { - console.log(`${url} is not available, status code: ${res.statusCode}`); +function getKeyByValue(data: any, value: string) { + return Object.keys(data).find(key => data[key] === value); +} + +for (const url of + [ + c.NHENTAI_IP_4, + c.HENTAIFOX, + c.PURURIN, + c.ASMHENTAI, + c.SIMPLY_HENTAI_PROXIFIED, + c.HENTAI2READ, + c.THREEHENTAI + ]) { + p({ + url: url, + headers: { + "User-Agent": `${name}/${version} Node.js/16.9.1`, + } + }).then(res => { + if (res.statusCode !== 200 && res.statusCode !== 308 && res.statusCode !== 301) { + throw new Error(`${url} of ${getKeyByValue(c, url)} is not available, status: ${res.statusCode}, couldn't be scrape`); } else { - console.log(`${url} is available, can be scraped`); + console.log(`${url} is available status: ${res.statusCode}, could be scrape`); } }); } \ No newline at end of file