UNPKG

rsshub

Version:
69 lines (68 loc) 2.86 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as config } from "./config-CCmw1BNE.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as renderComic } from "./comic-C5budFhR.mjs"; import pMap from "p-map"; //#region lib/routes/zaimanhua/update.ts const route = { path: "/update", categories: ["anime"], example: "/zaimanhua/update", features: { requireConfig: [{ name: "ZAIMANHUA_TOKEN", optional: true, description: "可从浏览器开发者工具中抓取站点请求头 `Authorization` 的 Bearer token,并配置为环境变量。可设置为完整值 `Bearer <token>`,或仅设置 token 由路由自动补齐 `Bearer ` 前缀。" }], requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false, nsfw: true }, radar: [{ source: ["manhua.zaimanhua.com/update"], target: "/update" }], name: "最近更新", maintainers: ["kjasn"], description: `::: Warning 建议设置\`ZAIMANHUA_TOKEN\`环境变量以使用 API 授权访问。且由于源网站本身的限制,建议尽量在部署于中国大陆网络内的 RSSHub 节点中使用本路由。若在海外网络环境中使用,即使设置了\`ZAIMANHUA_TOKEN\`环境变量,也可能无法获取全部漫画。 :::`, handler: async () => { const baseUrl = "https://manhua.zaimanhua.com"; const currentUrl = `${baseUrl}/api/v1/comic2/update_list?status&theme&zone&cate&firstLetter&sortType&page=1&size=20`; const headers = { "user-agent": config.trueUA }; const token = config.zaimanhua.token; if (token) headers.Authorization = token.startsWith("Bearer ") ? token : `Bearer ${token}`; const updateData = (await rofetch(currentUrl, { headers })).data.comicList; const items = await pMap(updateData, async (item) => { const comicId = item.id; const lastUpdateChapterId = item.last_update_chapter_id; const comicPy = item.comic_py; const chapterUrl = `${baseUrl}/api/v1/comic2/chapter/detail?comic_id=${comicId}&chapter_id=${lastUpdateChapterId}`; return await cache_default.tryGet(chapterUrl, async () => { const chapterData = (await rofetch(chapterUrl, { headers })).data; const description = renderComic(chapterData.chapterInfo.page_url || []); return { title: `[${item.status}] | ${item.name} - ${item.last_update_chapter_name}`, author: item.authors, category: [item.status, ...item.types.split("/")], image: item.cover, link: `${baseUrl}/view/${comicPy}/${comicId}/${lastUpdateChapterId}`, pubDate: parseDate(item.last_updatetime * 1e3), description }; }); }, { concurrency: 3 }); return { title: "再漫画 - 最近更新", link: `${baseUrl}/update`, item: items }; } }; //#endregion export { route };