UNPKG

rsshub

Version:
63 lines (61 loc) 1.7 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as rss_parser_default } from "./rss-parser-Dtop7M8f.mjs"; import { load } from "cheerio"; //#region lib/routes/jandan/index.ts const route = { path: "/", example: "/jandan", name: "Feed", maintainers: [ "nczitzk", "bigfei", "pseudoyu" ], parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["i.jandan.net"], target: "/jandan" }], handler }; async function handler() { const rootUrl = "http://i.jandan.net"; const feed = await rss_parser_default.parseURL(`${rootUrl}/feed/`); return { title: "煎蛋", link: rootUrl, item: await Promise.all(feed.items.map((item) => cache_default.tryGet(item.link || "", async () => { if (!item.link) return; const $ = load(await ofetch_default(item.link)); $(".wechat-hide").prev().nextAll().remove(); $("img").replaceWith((i, e) => { const src = $(e).attr("src"); const alt = $(e).attr("alt"); return `<img src="${src?.replace(/https?:\/\/(\w+)\.moyu\.im/, "https://$1.sinaimg.cn")}" alt="${alt}">`; }); return { title: item.title || "", description: $(".entry").html() || "", pubDate: item.pubDate, link: item.link, author: item["dc:creator"], category: item.categories }; }))).then((items) => items.filter((item) => item !== void 0)) }; } //#endregion export { route };