UNPKG

rsshub

Version:
108 lines (106 loc) 3.46 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 { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import path from "node:path"; //#region lib/routes/asus/bios.ts init_esm_shims(); const endPoints = { zh: { url: "https://odinapi.asus.com.cn/", lang: "cn", websiteCode: "cn" }, en: { url: "https://odinapi.asus.com/", lang: "en", websiteCode: "global" } }; const getProductInfo = (model, language) => { const { url, lang, websiteCode } = endPoints[language] ?? endPoints.zh; const searchAPI = `${url}recent-data/apiv2/SearchSuggestion?SystemCode=asus&WebsiteCode=${websiteCode}&SearchKey=${model}&SearchType=ProductsAll&RowLimit=4&sitelang=${lang}`; return cache_default.tryGet(`asus:bios:${model}:${language}`, async () => { const product = (await ofetch_default(searchAPI)).Result[0].Content[0]; return { productID: product.DataId, hashId: product.HashId, url: product.Url, title: product.Title, image: product.ImageURL, m1Id: product.M1Id, productLine: product.ProductLine }; }); }; const route = { path: "/bios/:model/:lang?", categories: ["program-update"], example: "/asus/bios/RT-AX88U/zh", parameters: { model: "Model, can be found in product page", lang: { description: "Language, provide access routes for other parts of the world", options: [{ label: "Chinese", value: "zh" }, { label: "Global", value: "en" }], default: "en" } }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: [ "www.asus.com/displays-desktops/:productLine/:series/:model", "www.asus.com/laptops/:productLine/:series/:model", "www.asus.com/motherboards-components/:productLine/:series/:model", "www.asus.com/networking-iot-servers/:productLine/:series/:model", "www.asus.com/:region/displays-desktops/:productLine/:series/:model", "www.asus.com/:region/laptops/:productLine/:series/:model", "www.asus.com/:region/motherboards-components/:productLine/:series/:model", "www.asus.com/:region/networking-iot-servers/:productLine/:series/:model" ], target: "/bios/:model" }], name: "BIOS", maintainers: ["Fatpandac"], handler, url: "www.asus.com" }; async function handler(ctx) { const model = ctx.req.param("model"); const language = ctx.req.param("lang") ?? "en"; const productInfo = await getProductInfo(model, language); const items = (await ofetch_default(language === "zh" ? `https://www.asus.com.cn/support/api/product.asmx/GetPDBIOS?website=cn&model=${model}&sitelang=cn` : `https://www.asus.com/support/api/product.asmx/GetPDBIOS?website=global&model=${model}&sitelang=en`)).Result.Obj[0].Files.map((item) => ({ title: item.Title, description: art(path.join(__dirname, "templates/bios-c84dd674.art"), { item, language }), guid: productInfo.url + item.Version, pubDate: parseDate(item.ReleaseDate, "YYYY/MM/DD"), link: productInfo.url })); return { title: `${productInfo.title} BIOS`, link: productInfo.url, image: productInfo.image, item: items }; } //#endregion export { route };