UNPKG

rsshub

Version:
63 lines (61 loc) 1.7 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import { t as rss_parser_default } from "./rss-parser-Cnh4NKwh.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 };