UNPKG

rsshub

Version:
99 lines (97 loc) 3.39 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import "./md5-C8GRvctM.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import "./got-KxxWdaxq.mjs"; import "./config-not-found-Dyp3RlZZ.mjs"; import { a as getRootUrl, i as getApiUrl, o as processApiItems, r as defaultDomain } from "./utils-ClP3Chfl.mjs"; import path from "node:path"; //#region lib/routes/18comic/album.ts init_esm_shims(); const route = { path: "/album/:id", categories: ["anime"], example: "/18comic/album/292282", parameters: { id: "专辑 id,可在专辑页 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false, nsfw: true }, radar: [{ source: ["jmcomic.group/"] }], name: "专辑", maintainers: ["nczitzk"], handler, url: "jmcomic.group/", description: `::: tip 专辑 id 不包括 URL 中标题的部分。 :::` }; async function handler(ctx) { const id = ctx.req.param("id"); const { domain = defaultDomain } = ctx.req.query(); const rootUrl = getRootUrl(domain); const currentUrl = `${rootUrl}/album/${id}`; const apiResult = await processApiItems(`${getApiUrl()}/album?id=${id}`); const category = apiResult.tags; const author = apiResult.author.join(", "); const description = apiResult.description; const addTime = apiResult.addtime; let results = []; if (apiResult.series.length === 0) results.push({ title: apiResult.name, link: `${rootUrl}/photo/${id}`, guid: `${rootUrl}/photo/${id}`, updated: /* @__PURE__ */ new Date(addTime * 1e3), pubDate: /* @__PURE__ */ new Date(addTime * 1e3), category, author, description: art(path.join(__dirname, "templates/description-afe7e434.art"), { introduction: description, images: [`https://cdn-msp3.${domain}/media/albums/${id}_3x4.jpg`], cover: `https://cdn-msp3.${domain}/media/albums/${id}_3x4.jpg`, category }) }); else { results = await Promise.all(apiResult.series.map((item, index) => cache_default.tryGet(`18comic:album:${item.id}`, async () => { const chapterResult = await processApiItems(`${getApiUrl()}/chapter?id=${item.id}`); const result = {}; const chapterNum = index + 1; result.title = `第${String(chapterNum)}${item.name === "" ? `${String(chapterNum)}` : item.name}`; result.link = `${rootUrl}/photo/${item.id}`; result.guid = `${rootUrl}/photo/${item.id}`; result.updated = /* @__PURE__ */ new Date(chapterResult.addtime * 1e3); result.pubDate = addTime; result.category = category; result.author = author; result.description = art(path.join(__dirname, "templates/description-afe7e434.art"), { introduction: description, images: [`https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`], cover: `https://cdn-msp3.${domain}/media/albums/${item.id}_3x4.jpg`, category }); return result; }))); results = results.toReversed(); } return { title: `${apiResult.name} - 禁漫天堂`, link: currentUrl.replace(/\?$/, ""), item: results, allowEmpty: true, description }; } //#endregion export { route };