UNPKG

rsshub

Version:
51 lines (50 loc) 1.94 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { load } from "cheerio"; //#region lib/routes/supremecourt/argument-audio.ts const route = { path: "/argument_audio/:year?", categories: ["government"], example: "/supremecourt/argument_audio", parameters: { year: "Year, current year by default" }, name: "Arguments Audios", maintainers: ["nczitzk"], handler }; async function handler(ctx) { const { year = (/* @__PURE__ */ new Date()).getFullYear() } = ctx.req.param(); const rootUrl = "https://www.supremecourt.gov"; const imageUrl = `${rootUrl}/images/scous_seal.png`; const currentUrl = `${rootUrl}/oral_arguments/argument_audio/${year}`; const $ = load(await rofetch(currentUrl)); const list = $(".card-body table tbody tr td span a").toArray().map((item) => { const $item = $(item); return { title: $item.text(), link: new URL($item.attr("href"), currentUrl).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load(await rofetch(item.link)); content("#pagetitle").remove(); item.description = content("#pagemaindiv").html() ?? void 0; item.title += ` : ${content("#ctl00_ctl00_MainEditable_mainContent_lblCaseName").text()}`; item.pubDate = timezone(parseDate(content("#ctl00_ctl00_MainEditable_mainContent_lblDate").text()), -5); item.itunes_item_image = imageUrl; item.enclosure_url = content("audio source").attr("src"); item.enclosure_type = "audio/mpeg"; return item; }))); return { title: `Argument Audio ${year} - Supreme Court of the United States`, link: currentUrl, item: items, itunes_author: "Supreme Court of the United States", image: imageUrl, allowEmpty: true }; } //#endregion export { route };