UNPKG

rsshub

Version:
97 lines (90 loc) 3.32 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 { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/gamersecret/index.ts const route = { path: "/:type?/:category?", categories: ["game"], example: "/gamersecret", parameters: { type: "Type, see below, Latest News by default", category: "Category, see below" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: [ "gamersecret.com/:type", "gamersecret.com/:type/:category", "gamersecret.com/" ] }], name: "Category", maintainers: ["nczitzk"], handler, description: `| Latest News | PC | Playstation | Nintendo | Xbox | Moblie | | ----------- | -- | ----------- | -------- | ---- | ------ | | latest-news | pc | playstation | nintendo | xbox | moblie | Or | GENERAL | GENERAL EN | MOBILE | MOBILE EN | | ---------------- | ------------------ | --------------- | ----------------- | | category/general | category/generalen | category/mobile | category/mobileen | | NINTENDO | NINTENDO EN | PC | PC EN | | ----------------- | ------------------- | ----------- | ------------- | | category/nintendo | category/nintendoen | category/pc | category/pcen | | PLAYSTATION | PLAYSTATION EN | REVIEWS | | -------------------- | ---------------------- | ---------------- | | category/playstation | category/playstationen | category/reviews | | XBOX | XBOX EN | | ------------- | --------------- | | category/xbox | category/xboxen |` }; async function handler(ctx) { const type = ctx.req.param("type") ?? "latest-news"; const category = ctx.req.param("category") ?? ""; const currentUrl = `https://www.gamersecret.com/${type}${category ? `/${category}` : ""}`; const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(".jeg_post_title a").slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 20).toArray().map((item) => { item = $(item); return { title: item.text(), link: item.attr("href") }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await got_default({ method: "get", url: item.link }); const content = load(detailResponse.data); content("img").each(function() { content(this).attr("src", content(this).attr("data-src")); }); item.author = content(".jeg_meta_author").text().replace(/by/, ""); item.pubDate = timezone(parseDate(detailResponse.data.match(/datePublished":"(.*)","dateModified/)[1]), 8); item.description = content(".thumbnail-container").html() + content(".elementor-text-editor, .content-inner").html(); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };