rsshub
Version:
Make RSS Great Again!
82 lines (80 loc) • 2.58 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
//#region lib/routes/komiic/comic.ts
const route = {
path: "/comic/:id",
categories: ["anime"],
example: "/komiic/comic/533",
parameters: { id: "漫画 ID" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true
},
radar: [{
source: ["komiic.com/comic/:id"],
target: "/comic/:id"
}],
name: "漫画更新",
maintainers: ["NekoAria"],
handler
};
async function handler(ctx) {
const { id } = ctx.req.param();
const { limit = 0 } = ctx.req.query();
const baseUrl = "https://komiic.com";
const { data: comicInfo } = await got_default.post(`${baseUrl}/api/query`, { json: {
operationName: "comicById",
variables: { comicId: id },
query: `query comicById($comicId: ID!) {
comicById(comicId: $comicId) {
title
imageUrl
}
}`
} });
const { title, imageUrl } = comicInfo.data.comicById;
const { data: chapterData } = await got_default.post(`${baseUrl}/api/query`, { json: {
operationName: "chapterByComicId",
variables: { comicId: id },
query: `query chapterByComicId($comicId: ID!) {
chaptersByComicId(comicId: $comicId) {
id
serial
type
dateUpdated
size
}
}`
} });
const sortedChapters = chapterData.data.chaptersByComicId.toSorted((a, b) => Date.parse(b.dateUpdated) - Date.parse(a.dateUpdated));
const chapterLimit = Number(limit) || sortedChapters.length;
const filteredChapters = sortedChapters.slice(0, chapterLimit);
const generateChapterDescription = (chapter) => `
<h1>${chapter.size}p</h1>
<img src="${imageUrl}" />
`.trim();
const items = filteredChapters.map((chapter) => ({
title: chapter.type === "book" ? `第 ${chapter.serial} 卷` : `第 ${chapter.serial} 话`,
link: `${baseUrl}/comic/${id}/chapter/${chapter.id}/images/all`,
pubDate: parseDate(chapter.dateUpdated),
description: generateChapterDescription(chapter)
}));
return {
title: `Komiic - ${title}`,
link: `${baseUrl}/comic/${id}`,
item: items
};
}
//#endregion
export { route };