UNPKG

rsshub

Version:
43 lines (42 loc) 1.56 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/gamer/utils.ts const fetchItem = (item) => cache_default.tryGet(item.link, async () => { const response = await rofetch(item.link); const $ = load(response); const content = $("#article_content, .card"); content.find(".form__buttonbar").remove(); content.find("a[href^=\"https://ref.gamer.com.tw/redir.php\"]").each((_, a) => { const url = new URL($(a).attr("href")).searchParams.get("url"); if (url) $(a).attr("href", url); }); content.prepend($("#div_illustration img").toArray().map((img) => `<img src="${$(img).parent().attr("data-src")}">`).join("")); return { ...item, description: content.html() }; }); const ProcessFeed = async (url) => { const response = await rofetch(url); const $ = load(response); const title = $("title").text(); const list = $(".platform-info-box").toArray().map((item) => { const $item = $(item); const a = $item.find(".HOME-mainwrap1 h1 > a"); return { title: a.text(), link: a.attr("href"), author: $item.find(".mainbox-author").text(), pubDate: timezone(parseDate($item.find(".caption-text").not(".height-limit").text().split("|", 2)[1]), 8) }; }); return { title, items: await Promise.all(list.map((item) => fetchItem(item))) }; }; //#endregion export { fetchItem as n, ProcessFeed as t };