UNPKG

rsshub

Version:
68 lines (66 loc) 2.18 kB
import { n as init_esm_shims, t as __dirname } from "./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 "./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/deadline/posts.ts init_esm_shims(); const route = { path: "/", radar: [{ source: ["deadline.com/"], target: "" }], name: "Unknown", maintainers: ["TonyRL"], handler, url: "deadline.com/" }; async function handler(ctx) { const baseUrl = "https://deadline.com"; const items = (await got_default(`${baseUrl}/wp-json/wp/v2/posts`, { searchParams: { per_page: ctx.req.query("limit") ?? 30, _embed: true } })).data.map((item) => { const embedded = item._embedded; const $ = load(item.content.rendered, null, false); $(".c-lazy-image__img").each((_, img) => { img = $(img); if (img.attr("data-lazy-src")) { img.attr("src", img.attr("data-lazy-src").split("?")[0]); img.removeAttr("data-lazy-src"); img.removeAttr("data-lazy-srcset"); } }); $("[class^=\"lrv-a-crop-\"]").contents().unwrap(); const description = art(path.join(__dirname, "templates/desc-af7249f8.art"), { desc: $.html(), embedded }); return { title: item.title.rendered, link: item.link, guid: item.guid.rendered, description, pubDate: parseDate(item.date_gmt), author: embedded.author[0].name, category: [...new Set([...embedded["wp:term"][0].map((i) => i.name), ...embedded["wp:term"][1].map((i) => i.name)])] }; }); return { title: "Deadline – Hollywood Entertainment Breaking News", description: "Deadline.com is always the first to break up-to-the-minute entertainment, Hollywood and media news, with an unfiltered, no-holds-barred analysis of events.", link: baseUrl, language: "en-US", image: `${baseUrl}/wp-content/themes/pmc-deadline-2019/assets/app/icons/apple-touch-icon.png`, item: items }; } //#endregion export { route };