UNPKG

rsshub

Version:
75 lines (73 loc) 2.9 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 { 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 dayjs from "dayjs"; import { load } from "cheerio"; //#region lib/routes/appstorrent/programs.ts init_esm_shims(); const route = { path: "/programs", categories: ["program-update"], example: "/appstorrent/programs", name: "Programs", maintainers: ["xzzpig"], handler, url: "appstorrent.ru/programs/" }; async function handler(ctx) { const limit = ctx?.req.query("limit") ? Number.parseInt(ctx?.req.query("limit") ?? "20") : 20; const baseUrl = "https://appstorrent.ru"; const currentUrl = `${baseUrl}/programs/`; const gotOptions = { http2: true }; const $ = load((await got_default(currentUrl, gotOptions)).data); const list = $("article.soft-item:not(.locked)").slice(0, limit).toArray().map((item) => { const $item = $(item); return { title: $item.find(".subtitle").text().trim(), link: $item.find(".subtitle a").attr("href"), category: [$item.find(".info .category").text().trim()], version: $item.find(".version").text(), architecture: $item.find(".architecture").text().trim(), size: $item.find(".size").text().trim() }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const $$1 = load((await got_default(item.link, gotOptions)).data); const pubDate = parseDate($$1(".tech-info .date-news a").attr("href")?.replace("https://appstorrent.ru/", "") ?? ""); return { title: item.title, link: item.link, category: item.category, pubDate, description: art(path.join(__dirname, "templates/description-9593c953.art"), { cover: baseUrl + $$1(".main-title img").attr("src")?.trim(), title: item.title, pubDate: dayjs(pubDate).format("YYYY-MM-DD"), version: item.version, architecture: item.architecture, compatibility: $$1("div.right > div.info > div.right-container > div:nth-child(5) > div > span:nth-child(2) > a").text(), size: item.size, activation: $$1("div.right > div.info > div.right-container > div:nth-child(4) > div > span:nth-child(2) > a").text(), description: $$1(".content .body-content").first().text(), changelog: $$1(".content .body-content").last().text(), screenshots: $$1(".screenshots img").toArray().map((img) => $$1(img).attr("src")).map((src) => baseUrl + src) }) }; }))); return { title: $("title").text(), link: currentUrl.toString(), allowEmpty: true, item: items }; } //#endregion export { route };