* handling error and proper status * push release
このコミットが含まれているのは:
コミット
c36177337e
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "jandapress",
|
||||
"version": "2.1.1-alpha",
|
||||
"version": "2.1.2-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": {
|
||||
|
@ -48,7 +48,7 @@
|
|||
"keyv": "^4.5.2",
|
||||
"phin": "^3.6.1",
|
||||
"pino": "^8.7.0",
|
||||
"pino-pretty": "^9.1.1",
|
||||
"pino-pretty": "^9.2.0",
|
||||
"tough-cookie": "^4.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -62,7 +62,7 @@
|
|||
"apidoc": "^0.29.0",
|
||||
"eslint": "^8.29.0",
|
||||
"npx": "^10.2.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rimraf": "^4.1.2",
|
||||
"start-server-and-test": "^1.14.0",
|
||||
"ts-node": "^10.8.1",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { isNumeric } from "../../utils/modifier";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function get3hentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function get3hentai(req: Request, res: Response) {
|
||||
try {
|
||||
const book = req.query.book as string;
|
||||
if (!book) throw Error("Parameter book is required");
|
||||
|
@ -49,7 +49,8 @@ export async function get3hentai(req: Request, res: Response, next: NextFunction
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
|
||||
export async function random3hentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function random3hentai(req: Request, res: Response) {
|
||||
try {
|
||||
/**
|
||||
* @api {get} /3hentai/random Random 3hentai
|
||||
|
@ -43,7 +44,8 @@ export async function random3hentai(req: Request, res: Response, next: NextFunct
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { scrapeContent } from "../../scraper/3hentai/3hentaiSearchController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
const sorting = ["recent", "popular-24h", "popular-7d", "popular"];
|
||||
|
||||
export async function search3hentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function search3hentai(req: Request, res: Response) {
|
||||
try {
|
||||
const key = req.query.key || "";
|
||||
const page = req.query.page || 1;
|
||||
|
@ -53,7 +54,8 @@ export async function search3hentai(req: Request, res: Response, next: NextFunct
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { isNumeric } from "../../utils/modifier";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function getAsmhentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function getAsmhentai(req: Request, res: Response) {
|
||||
try {
|
||||
const book = req.query.book as string;
|
||||
if (!book) throw Error("Parameter book is required");
|
||||
|
@ -49,7 +49,8 @@ export async function getAsmhentai(req: Request, res: Response, next: NextFuncti
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function randomAsmhentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function randomAsmhentai(req: Request, res: Response) {
|
||||
try {
|
||||
/**
|
||||
* @api {get} /asmhentai/random Random asmhentai
|
||||
|
@ -43,7 +44,8 @@ export async function randomAsmhentai(req: Request, res: Response, next: NextFun
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiSearchController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function searchAsmhentai(req: Request, res: Response, next: NextFunction) {
|
||||
export async function searchAsmhentai(req: Request, res: Response) {
|
||||
try {
|
||||
const key = req.query.key || "";
|
||||
const page = req.query.page || 1;
|
||||
|
@ -49,7 +50,8 @@ export async function searchAsmhentai(req: Request, res: Response, next: NextFun
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { scrapeContent } from "../../scraper/hentai2read/hentai2readGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function getHentai2read(req: Request, res: Response) {
|
||||
|
@ -48,11 +49,8 @@ export async function getHentai2read(req: Request, res: Response) {
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
const example = {
|
||||
"success": false,
|
||||
"message": err.message
|
||||
};
|
||||
res.json(example);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/hentai2read/hentai2readSearchController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function searchHentai2read(req: Request, res: Response, next: NextFunction) {
|
||||
export async function searchHentai2read(req: Request, res: Response) {
|
||||
try {
|
||||
const key = req.query.key || "";
|
||||
if (!key) throw Error("Parameter book is required");
|
||||
|
@ -46,7 +47,8 @@ export async function searchHentai2read(req: Request, res: Response, next: NextF
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { isNumeric } from "../../utils/modifier";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function getHentaifox(req: Request, res: Response, next: NextFunction) {
|
||||
export async function getHentaifox(req: Request, res: Response) {
|
||||
try {
|
||||
const book = req.query.book as string;
|
||||
if (!book) throw Error("Parameter book is required");
|
||||
|
@ -49,7 +49,8 @@ export async function getHentaifox(req: Request, res: Response, next: NextFuncti
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { Request, Response, NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
|
||||
export async function randomHentaifox(req: Request, res: Response, next: NextFunction) {
|
||||
export async function randomHentaifox(req: Request, res: Response) {
|
||||
try {
|
||||
/**
|
||||
* @api {get} /hentaifox/random Random hentaifox
|
||||
|
@ -42,7 +43,8 @@ export async function randomHentaifox(req: Request, res: Response, next: NextFun
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxSearchController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
const sorting = ["latest", "popular"];
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function searchHentaifox(req: Request, res: Response, next: NextFunction) {
|
||||
export async function searchHentaifox(req: Request, res: Response) {
|
||||
try {
|
||||
/**
|
||||
* @api {get} /hentaifox/search Search hentaifox
|
||||
|
@ -52,7 +53,8 @@ export async function searchHentaifox(req: Request, res: Response, next: NextFun
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { isNumeric } from "../../utils/modifier";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function getPururin(req: Request, res: Response, next: NextFunction) {
|
||||
export async function getPururin(req: Request, res: Response) {
|
||||
try {
|
||||
const book = req.query.book as string;
|
||||
if (!book) throw Error("Parameter book is required");
|
||||
|
@ -49,7 +49,8 @@ export async function getPururin(req: Request, res: Response, next: NextFunction
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { getIdRandomPururin } from "../../utils/modifier";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { getIdRandomPururin, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function randomPururin(req: Request, res: Response, next: NextFunction) {
|
||||
export async function randomPururin(req: Request, res: Response) {
|
||||
try {
|
||||
const id = await getIdRandomPururin();
|
||||
|
||||
|
@ -46,7 +46,8 @@ export async function randomPururin(req: Request, res: Response, next: NextFunct
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
import { scrapeContent } from "../../scraper/pururin/pururinSearchController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { maybeError } from "../../utils/modifier";
|
||||
const sorting = ["newest", "most-popular", "highest-rated", "most-viewed", "title", "random"];
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function searchPururin(req: Request, res: Response, next: NextFunction) {
|
||||
export async function searchPururin(req: Request, res: Response) {
|
||||
try {
|
||||
const key = req.query.key as string;
|
||||
const page = req.query.page || 1;
|
||||
|
@ -53,7 +54,8 @@ export async function searchPururin(req: Request, res: Response, next: NextFunct
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
next(Error(err.message));
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { scrapeContent } from "../../scraper/simply-hentai/simply-hentaiGetController";
|
||||
import c from "../../utils/options";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { mock } from "../../utils/modifier";
|
||||
import { mock, maybeError } from "../../utils/modifier";
|
||||
import { Request, Response } from "express";
|
||||
|
||||
export async function getSimplyhentai(req: Request, res: Response) {
|
||||
|
@ -51,11 +51,8 @@ export async function getSimplyhentai(req: Request, res: Response) {
|
|||
useragent: req.get("User-Agent")
|
||||
});
|
||||
return res.json(data);
|
||||
} catch (err: any) {
|
||||
const example = {
|
||||
"success": false,
|
||||
"message": err.message
|
||||
};
|
||||
res.json(example);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
res.status(400).json(maybeError(false, e.message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ interface IGet3hentai {
|
|||
|
||||
}
|
||||
|
||||
interface IData{
|
||||
interface IData {
|
||||
success?: boolean;
|
||||
data: object;
|
||||
source: string;
|
||||
}
|
||||
|
@ -34,6 +35,8 @@ export async function scrapeContent(url: string) {
|
|||
const tags = $("span.filter-elem")?.map((i, el) => $(el).text()).get();
|
||||
const tagsClean = tags.map((tag: string) => tag.replace(/<[^>]*>/g, "").replace(/\n/g, "").trim());
|
||||
const image = $("div.single-thumb-col")?.map((i, el) => $(el).find("img").attr("data-src")).get();
|
||||
if (image.length === 0) throw Error("No result found");
|
||||
|
||||
const imageClean = image.map((img: string) => img.replace("t.", "."));
|
||||
const upload_date = $("time").text();
|
||||
|
||||
|
@ -47,12 +50,13 @@ export async function scrapeContent(url: string) {
|
|||
};
|
||||
|
||||
const data: IData = {
|
||||
success: true,
|
||||
data: objectData,
|
||||
source: `${c.THREEHENTAI}/d/${id ? id : book}`,
|
||||
};
|
||||
return data;
|
||||
} catch (err) {
|
||||
const error = err as string;
|
||||
throw new Error(error);
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -38,7 +38,10 @@ export async function scrapeContent(url: string) {
|
|||
content.push(objectData);
|
||||
}
|
||||
|
||||
if (content.length === 0) throw Error("No result found");
|
||||
|
||||
const data = {
|
||||
success: true,
|
||||
data: content,
|
||||
page: parseInt(url.split("&page=")[1]),
|
||||
sort: url.split("sort=")[1],
|
||||
|
@ -47,7 +50,7 @@ export async function scrapeContent(url: string) {
|
|||
return data;
|
||||
|
||||
} catch (err) {
|
||||
const error = err as string;
|
||||
throw new Error(error);
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,8 @@ interface IGetAsmhentai {
|
|||
upload_date: string;
|
||||
}
|
||||
|
||||
interface IData{
|
||||
interface IData {
|
||||
success?: boolean;
|
||||
data: object;
|
||||
source: string;
|
||||
}
|
||||
|
@ -43,6 +44,8 @@ export async function scrapeContent(url: string) {
|
|||
image.push(`${imageUrl.replace("cover", `${i + 1}`)}`);
|
||||
}
|
||||
|
||||
if (image.length === 0) throw Error("Not found");
|
||||
|
||||
const objectData: IGetAsmhentai = {
|
||||
title: title,
|
||||
id: actualBook,
|
||||
|
@ -53,12 +56,13 @@ export async function scrapeContent(url: string) {
|
|||
};
|
||||
|
||||
const data: IData = {
|
||||
success: true,
|
||||
data: objectData,
|
||||
source: `${c.ASMHENTAI}/g/${actualBook}/`
|
||||
};
|
||||
return data;
|
||||
} catch (err) {
|
||||
const error = err as string;
|
||||
throw new Error(error);
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -37,17 +37,20 @@ export async function scrapeContent(url: string) {
|
|||
|
||||
};
|
||||
content.push(objectData);
|
||||
|
||||
}
|
||||
|
||||
if (content.length === 0) throw Error("No result found");
|
||||
|
||||
const data = {
|
||||
success: true,
|
||||
data: content,
|
||||
page: parseInt(url.split("&page=")[1]),
|
||||
sort: url.split("/search/")[1].split("?")[0],
|
||||
source: url
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -45,7 +45,8 @@ export async function scrapeContent(url: string) {
|
|||
previus_url: gDataJson.previousURL
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -35,12 +35,15 @@ export async function scrapeContent(url: string) {
|
|||
|
||||
}
|
||||
|
||||
if (content.length === 0) throw Error("No result found");
|
||||
|
||||
const data = {
|
||||
data: content,
|
||||
source: url,
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -48,11 +48,13 @@ export async function scrapeContent(url: string) {
|
|||
};
|
||||
|
||||
const data = {
|
||||
success: true,
|
||||
data: objectData,
|
||||
source: `${c.HENTAIFOX}/gallery/${id}/`,
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -48,14 +48,19 @@ export async function scrapeContent(url: string) {
|
|||
|
||||
}
|
||||
|
||||
if (content.length === 0) throw Error("No result found");
|
||||
|
||||
|
||||
const data = {
|
||||
success: true,
|
||||
data: content.filter(con => con.category !== ""),
|
||||
page: Number(url.split("&page=")[1]),
|
||||
sort: url.split("&sort=")[1].split("&")[0],
|
||||
source: url,
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,8 @@ interface IGetPururin {
|
|||
image: string[];
|
||||
}
|
||||
|
||||
interface IData{
|
||||
interface IData {
|
||||
success: boolean;
|
||||
data: object;
|
||||
source: string;
|
||||
}
|
||||
|
@ -28,6 +29,7 @@ export async function scrapeContent(url: string, random = false) {
|
|||
|
||||
const $ = load(raw);
|
||||
const title: string = $("div.content-wrapper h1").html() || "";
|
||||
if (!title) throw Error("Not found");
|
||||
|
||||
const tags: string[] = $("div.content-wrapper ul.list-inline li").map((i, abc) => {
|
||||
return getPururinInfo($(abc).text());
|
||||
|
@ -53,11 +55,13 @@ export async function scrapeContent(url: string, random = false) {
|
|||
};
|
||||
|
||||
const data: IData = {
|
||||
success: true,
|
||||
data: objectData,
|
||||
source: `${c.PURURIN}/gallery/${id}/janda`
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ interface ISearchPururin {
|
|||
}
|
||||
|
||||
interface IData {
|
||||
success: boolean;
|
||||
data: object;
|
||||
page: number;
|
||||
sort: string;
|
||||
|
@ -55,14 +56,18 @@ export async function scrapeContent(url: string) {
|
|||
|
||||
}
|
||||
|
||||
if (content.length === 0) throw Error("No result found");
|
||||
|
||||
const data: IData = {
|
||||
success: true,
|
||||
data: content,
|
||||
page: parseInt(url.split("&page=")[1]),
|
||||
sort: url.split("/search/")[1].split("?")[0],
|
||||
source: c.PURURIN
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
|
@ -37,11 +37,13 @@ export async function scrapeContent(url: string) {
|
|||
};
|
||||
|
||||
const data = {
|
||||
success: true,
|
||||
data: objectData,
|
||||
source: url,
|
||||
};
|
||||
return data;
|
||||
} catch (err: any) {
|
||||
throw Error(err.message);
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
throw Error(e.message);
|
||||
}
|
||||
}
|
読み込み中…
新しいイシューから参照