UNPKG

rsshub

Version:
60 lines (58 loc) 1.96 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.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 art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/natgeo/dailyphoto.ts init_esm_shims(); const route = { path: "/dailyphoto", categories: ["picture"], view: ViewType.Pictures, example: "/natgeo/dailyphoto", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["nationalgeographic.com/photo-of-the-day/*", "nationalgeographic.com/"] }], name: "Daily Photo", maintainers: [ "LogicJake", "OrangeEd1t", "TonyRL", "pseudoyu" ], handler, url: "nationalgeographic.com/photo-of-the-day/*" }; async function handler() { const rootUrl = "https://www.nationalgeographic.com"; const apiUrl = `${rootUrl}/photo-of-the-day`; const $ = load(await cache_default.tryGet(apiUrl, async () => (await got_default(apiUrl)).data, config.cache.contentExpire, false)); return { title: "Nat Geo Photo of the Day", link: apiUrl, item: JSON.parse($.html().match(/window\['__natgeo__']=(.*);/)[1]).page.content.mediaspotlight.frms[0].mods[0].edgs[1].media.map((item) => ({ title: item.meta.title, description: art(path.join(__dirname, "templates/dailyPhoto-0ed56669.art"), { img: item.img }), link: rootUrl + item.locator, pubDate: parseDate(item.caption.preHeading), author: item.img.crdt })) }; } //#endregion export { route };