feat(nhentai): staged changes
このコミットが含まれているのは:
コミット
0d9215d4dd
|
@ -10,7 +10,7 @@ export async function getNhentai(req: any, res: any) {
|
||||||
if (isNaN(book)) throw Error("Value must be number");
|
if (isNaN(book)) throw Error("Value must be number");
|
||||||
|
|
||||||
let actualAPI;
|
let actualAPI;
|
||||||
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP_2;
|
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP;
|
||||||
|
|
||||||
const url = `${actualAPI}/api/gallery/${book}`;
|
const url = `${actualAPI}/api/gallery/${book}`;
|
||||||
const data = await scrapeContent(url);
|
const data = await scrapeContent(url);
|
||||||
|
|
|
@ -10,7 +10,7 @@ export async function relatedNhentai(req: any, res: any) {
|
||||||
if (isNaN(book)) throw Error("Value must be number");
|
if (isNaN(book)) throw Error("Value must be number");
|
||||||
|
|
||||||
let actualAPI;
|
let actualAPI;
|
||||||
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP_2;
|
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP;
|
||||||
|
|
||||||
const url = `${actualAPI}/api/gallery/${book}/related`;
|
const url = `${actualAPI}/api/gallery/${book}/related`;
|
||||||
const data = await scrapeContent(url);
|
const data = await scrapeContent(url);
|
||||||
|
|
|
@ -13,7 +13,7 @@ export async function searchNhentai(req: any, res: any) {
|
||||||
if (!sorting.includes(sort)) throw Error("Invalid short: " + sorting.join(", "));
|
if (!sorting.includes(sort)) throw Error("Invalid short: " + sorting.join(", "));
|
||||||
|
|
||||||
let actualAPI;
|
let actualAPI;
|
||||||
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP_2;
|
if (!await mock(c.NHENTAI)) actualAPI = c.NHENTAI_IP;
|
||||||
|
|
||||||
const url = `${actualAPI}/api/galleries/search?query=${key}&sort=${sort}&page=${page}`;
|
const url = `${actualAPI}/api/galleries/search?query=${key}&sort=${sort}&page=${page}`;
|
||||||
const data = await scrapeContent(url);
|
const data = await scrapeContent(url);
|
||||||
|
|
|
@ -1,4 +1,29 @@
|
||||||
import p from "phin";
|
import p from "phin";
|
||||||
|
import { CookieJar } from "tough-cookie";
|
||||||
|
import { HttpsCookieAgent } from "http-cookie-agent/http";
|
||||||
|
import { config } from "dotenv";
|
||||||
|
import * as pkg from "../../package.json";
|
||||||
|
config();
|
||||||
|
|
||||||
|
const jar = new CookieJar();
|
||||||
|
jar.setCookie(process.env.CF as string, "https://nhentai.net/");
|
||||||
|
|
||||||
|
async function nhentaiStatus(): Promise<boolean> {
|
||||||
|
const res = await p({
|
||||||
|
url: "https://nhentai.net/api/galleries/search?query=futanari",
|
||||||
|
core: {
|
||||||
|
agent: new HttpsCookieAgent({ cookies: { jar, }, }),
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": `jandapress/${pkg.version} Node.js/16.9.1`
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getPururinInfo(value: string) {
|
function getPururinInfo(value: string) {
|
||||||
return value.replace(/\n/g, " ").replace(/\s\s+/g, " ").trim();
|
return value.replace(/\n/g, " ").replace(/\s\s+/g, " ").trim();
|
||||||
|
@ -62,4 +87,4 @@ export const isNumeric = (val: string) : boolean => {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export { getPururinInfo, getPururinPageCount, getUrl, getId, getDate, timeAgo, mock };
|
export { getPururinInfo, getPururinPageCount, getUrl, getId, getDate, timeAgo, mock, nhentaiStatus };
|
|
@ -0,0 +1,24 @@
|
||||||
|
import p from "phin";
|
||||||
|
import { CookieJar } from "tough-cookie";
|
||||||
|
import { HttpsCookieAgent } from "http-cookie-agent/http";
|
||||||
|
import { config } from "dotenv";
|
||||||
|
config();
|
||||||
|
|
||||||
|
const jar = new CookieJar();
|
||||||
|
jar.setCookie("cf_clearance=HBMSCcaARc4EO7JkODYxsgfCoxqBX1gxyRswiHL5VZ4-1654510626-0-150", "https://nhentai.net/");
|
||||||
|
|
||||||
|
async function test() {
|
||||||
|
const res = await p({
|
||||||
|
url: "https://nhentai.net/api/galleries/search?query=mother",
|
||||||
|
core: {
|
||||||
|
agent: new HttpsCookieAgent({ cookies: { jar, }, }),
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": "jandapress/1.0.5 Node.js/16.9.1" // nhentai-api-client/3.4.3 Node.js/16.9.1
|
||||||
|
},
|
||||||
|
});
|
||||||
|
//check status
|
||||||
|
console.log(res.statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
test();
|
読み込み中…
新しいイシューから参照