UNPKG

rsshub

Version:
90 lines (88 loc) 2.46 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { load } from "cheerio"; //#region lib/routes/ifanr/digest.ts const handler = async (ctx) => { const limit = Number.parseInt(ctx.req.query("limit") ?? "20", 10); const baseUrl = "https://www.ifanr.com"; const apiBaseUrl = "https://sso.ifanr.com"; const targetUrl = new URL("digest", baseUrl).href; const apiUrl = new URL("api/v5/wp/buzz", apiBaseUrl).href; const response = await ofetch_default(apiUrl, { query: { limit, offset: 0 } }); const $ = load(await ofetch_default(targetUrl)); const language = $("html").attr("lang") ?? "zh-CN"; const items = response.objects.slice(0, limit).map((item) => { const title$1 = item.post_title; const description = item.post_content; const pubDate = item.created_at; const linkUrl = `digest/${item.post_id}`; const guid = `ifanr-digest-${item.post_id}`; const updated = item.updated_at ?? pubDate; return { title: title$1, description, pubDate: pubDate ? parseDate(pubDate, "X") : void 0, link: new URL(linkUrl, baseUrl).href, guid, id: guid, content: { html: description, text: item.post_content ?? description }, updated: updated ? parseDate(updated) : void 0, language, _extra: { links: [{ url: item.buzz_original_url, type: "via", content_html: item.post_content }] } }; }); const title = $("title").text(); return { title, description: title, link: targetUrl, item: items, allowEmpty: true, image: $("img.c-header-navbar__logo").attr("src"), author: $("meta[property=\"og:site_name\"]").attr("content"), language, id: $("meta[property=\"og:url\"]").attr("content") }; }; const route = { path: "/digest", name: "快讯", url: "www.ifanr.com", maintainers: ["nczitzk"], handler, example: "/ifanr/digest", parameters: void 0, description: void 0, categories: ["new-media"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.ifanr.comdigest"], target: "/digest" }], view: ViewType.Articles }; //#endregion export { handler, route };