rsshub
Version:
Make RSS Great Again!
37 lines (36 loc) • 1.05 kB
JavaScript
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { i as parseList, n as fetchItem, r as getSafeLineCookieWithData, t as baseUrl } from "./utils-BnlEr9yL.mjs";
import { load } from "cheerio";
import pMap from "p-map";
//#region lib/routes/zaker/channel.ts
const route = {
path: "/channel/:id?",
parameters: { id: "分类 ID,可在 URL 中找到,默认为 `1`" },
radar: [{
source: ["www.myzaker.com/channel/:id"],
target: "/channel/:id"
}],
name: "分类",
example: "/zaker/channel/13",
maintainers: [
"LogicJake",
"kt286",
"TonyRL"
],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id") ?? 1;
const link = `${baseUrl}/channel/${id}`;
const { cookie, data } = await getSafeLineCookieWithData(link);
const $ = load(data);
const feedTitle = $("head title").text();
const list = parseList($);
return {
title: feedTitle,
link,
item: await pMap(list, (item) => cache_default.tryGet(item.link, () => fetchItem(item, cookie)), { concurrency: 2 })
};
}
//#endregion
export { route };