UNPKG

rsshub

Version:
59 lines (58 loc) 1.75 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { load } from "cheerio"; //#region lib/routes/company3/index.ts const route = { path: "/:category?", categories: ["design"], example: "/company3/features", parameters: { category: { description: "Category", options: [ "commercials", "features", "television", "sound" ].map((c) => ({ value: c, label: c })), default: "commercials" } }, radar: [{ source: ["www.company3.com/video-categories/:category"], target: "/:category" }], name: "Video Categories", maintainers: ["MisteryMonster"], handler, url: "www.company3.com" }; async function handler(ctx) { const { category = "commercials" } = ctx.req.param(); const link = `https://www.company3.com/video-categories/${category}/`; const $ = load(await rofetch(link)); const list = $("div.preview.video div.details a").toArray().slice(0, ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 20).map((item) => { const $item = $(item); return { title: $item.find("h4.title").text(), link: $item.attr("href") }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const article = load(await rofetch(item.link))("article"); article.find(".social.share").remove(); const iframeSrc = article.find("iframe").attr("src"); item.author = article.find(".entry-header .subtitle").text(); item.description = (iframeSrc ? `<iframe src="${iframeSrc}" allowfullscreen></iframe>` : "") + article.find(".entry-content").html(); return item; }))); return { title: `Company 3 | ${category}`, link, language: "en", item: items }; } //#endregion export { route };