UNPKG

rsshub

Version:
65 lines (63 loc) 2.2 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/vom/featured.ts const baseUrl = "http://www.vom.mn"; const route = { path: "/featured/:lang?", categories: ["traditional-media"], example: "/vom/featured", parameters: { lang: "Language, see the table below, `mn` by default" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["vom.mn/:lang", "vom.mn/"], target: "/featured/:lang" }], name: "News", maintainers: ["TonyRL"], handler, description: `| English | 日本語 | Монгол | Русский | 简体中文 | | ------- | ------ | ------ | ------- | -------- | | en | ja | mn | ru | zh |` }; async function handler(ctx) { const { lang = "mn" } = ctx.req.param(); const { data: response } = await got_default(`${baseUrl}/${lang}`); const $ = load(response); const items = [...new Set($("#bigNewsSlide .item, #news_3 .item").toArray().map((item) => { item = $(item); return { link: item.find("a").eq(0).attr("href") }; }))]; await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); const $$1 = load(response$1); item.title = $$1("h2").text(); item.author = $$1(".uk-border-circle").next().text(); item.pubDate = parseDate($$1(".vom-news-show-meta .right").prev().text()); item.category = $$1(".vom-news-show-meta .uk-button-text").text(); $$1(".uk-article-title, .uk-text-meta, article .uk-grid-small").remove(); item.description = $$1("article").html(); return item; }))); return { title: $("meta[name=description]").attr("content"), image: "http://www.vom.mn/dist/images/vom-logo.png", item: items }; } //#endregion export { route };