UNPKG

rsshub

Version:
49 lines (48 loc) 1.67 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/monsterhunter/world-iceborne-news.ts const route = { path: "/world-iceborne/news", categories: ["game"], example: "/monsterhunter/world-iceborne/news", radar: [{ source: ["www.monsterhunter.com/", "www.monsterhunter.com/*path"] }], name: "World: Iceborne 最新消息", maintainers: ["DIYgod"], handler }; async function handler() { const url = "https://www.monsterhunter.com/world-iceborne/cn/news/"; const list = (await rofetch(`https://www.monsterhunter.com/world-iceborne/assets/data/cn/news.json?_=${Date.now()}`)).topics.map((item) => ({ title: item.text, img: item.img, link: new URL(item.link, "https://www.monsterhunter.com").href, isExternal: item.linkType === "_blank" })); return { title: "怪物猎人世界最新消息", link: url, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { let title, description; if (item.isExternal) { title = item.title; description = `<img src="https://www.monsterhunter.com/world-iceborne/${item.img}">`; } else try { const $ = load(await rofetch(item.link.replace("/cn/", "/") + "inc/contents_cn.html")); title = $(".bg-h2").text().trim(); description = $("#contents").html(); } catch { title = item.title; description = `<img src="https://www.monsterhunter.com/world-iceborne/${item.img}">`; } return { title, description, link: item.link, author: "MONSTER HUNTER WORLD: ICEBORNE" }; }))) }; } //#endregion export { route };