pururin update

このコミットが含まれているのは:
sinkaroid 2023-08-04 19:18:30 +07:00
コミット c8cadf5dea
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: ABD69470B2390135
2個のファイルの変更16行の追加15行の削除

ファイルの表示

@ -28,7 +28,8 @@ export async function scrapeContent(url: string, random = false) {
else res = await janda.fetchBody(url), raw = res;
const $ = load(raw);
const title: string = $("div.content-wrapper h1").html() || "";
const title: string = $("meta[property='og:title']").attr("content") || "";
if (!title) throw Error("Not found");
const tags: string[] = $("div.content-wrapper ul.list-inline li").map((i, abc) => {
@ -37,8 +38,8 @@ export async function scrapeContent(url: string, random = false) {
const cover = $("meta[property='og:image']").attr("content");
const extension = `.${cover?.split(".").pop()}`;
const total: number = parseInt($("gallery-thumbnails").attr(":total") || "0");
const id: number = parseInt($("gallery-thumbnails").attr(":id") || "0");
const total: number = parseInt($("span[itemprop='numberOfPages']").text()) || 0;
const id: number = parseInt($("meta[property='og:url']").attr("content")?.split("/")[4] || "0");
const image = [];
for (let i = 0; i < total; i++) {

ファイルの表示

@ -1,12 +1,11 @@
import { load } from "cheerio";
import JandaPress from "../../JandaPress";
import c from "../../utils/options";
import { isText } from "domhandler";
import { getPururinInfo, getPururinPageCount, getPururinLanguage } from "../../utils/modifier";
interface ISearchPururin {
title: string;
cover: string;
cover: string | null;
id: number;
language: string;
info: string;
@ -18,7 +17,7 @@ interface IData {
success: boolean;
data: object;
page: number;
sort: string;
sort: string | null;
source: string;
}
@ -28,8 +27,11 @@ export async function scrapeContent(url: string) {
try {
const res = await janda.fetchBody(url);
const $ = load(res);
const dataRaw = $("img.card-img-top");
const dataRaw = $(".card.card-gallery");
const info = $("div.info");
const card = $("img.card-img-top").map((i, abc) => {
return abc.attribs["src"];
}).get();
const infoBook = [];
for (let i = 0; i < info.length; i++) {
@ -39,21 +41,19 @@ export async function scrapeContent(url: string) {
}
}
const content = [];
for (const abc of dataRaw) {
const objectData: ISearchPururin = {
title: abc.attribs["alt"],
cover: abc.attribs["data-src"].replace(/^\/\//, "https://"),
id: parseInt(abc.attribs["data-src"].split("data/")[1].split("/cover")[0]),
title: abc.attribs["title"],
cover: card ? card[dataRaw.index(abc)] : null,
id: parseInt(abc.attribs["data-gid"]),
language: getPururinLanguage(infoBook[dataRaw.index(abc)]) || "Unknown",
info: infoBook[dataRaw.index(abc)],
link: `${c.PURURIN}/gallery/${abc.attribs["data-src"].split("data/")[1].split("/cover")[0]}/janda`,
link: abc.attribs["data-href"],
total: getPururinPageCount(infoBook[dataRaw.index(abc)])
};
content.push(objectData);
}
if (content.length === 0) throw Error("No result found");
@ -62,8 +62,8 @@ export async function scrapeContent(url: string) {
success: true,
data: content,
page: parseInt(url.split("&page=")[1]),
sort: url.split("/search/")[1].split("?")[0],
source: c.PURURIN
sort: null,
source: url
};
return data;
} catch (err) {