UNPKG

rsshub

Version:
59 lines (57 loc) 1.93 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/firefox/addons.ts const route = { path: "/addons/:id", categories: ["program-update"], example: "/firefox/addons/rsshub-radar", parameters: { id: "Add-ons id, can be found in add-ons url" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["addons.mozilla.org/:lang/firefox/addon/:id/versions", "addons.mozilla.org/:lang/firefox/addon/:id"] }], name: "Add-ons Update", maintainers: ["DIYgod"], handler }; async function handler(ctx) { const id = ctx.req.param("id"); const response = await got_default({ method: "get", url: `https://addons.mozilla.org/zh-CN/firefox/addon/${id}/versions/` }); const data = JSON.parse(load(response.data)("#redux-store-state").text()); const info = data.addons.byID[data.addons.bySlug[id]]; const versionIds = data.versions.bySlug[id].versionIds; return { title: `${info.name} - Firefox Add-on`, description: info.summary || info.description, link: `https://addons.mozilla.org/zh-CN/firefox/addon/${id}/versions/`, item: versionIds && versionIds.map((versionId) => { const versionInfo = data.versions.byId[versionId]; const version = "v" + versionInfo.version; return { title: version, description: versionInfo.releaseNotes || "", link: `https://addons.mozilla.org/zh-CN/firefox/addon/${id}/versions/`, pubDate: new Date(versionInfo.file.created), guid: version, author: info.authors.map((author) => author.name).join(", "), category: info.categories }; }) }; } //#endregion export { route };