UNPKG

rsshub

Version:
90 lines (88 loc) 2.6 kB
import "./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"; //#region lib/routes/modelscope/learn.ts const route = { path: "/learn", categories: ["programming"], example: "/modelscope/learn", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.modelscope.cn/learn"] }], name: "研习社", maintainers: ["TonyRL"], handler, url: "www.modelscope.cn/learn" }; const uselessKey = new Set([ "data-type", "ind", "jc", "list", "metadata", "newcode", "spacing", "subtype", "sz", "szunit", "uuid" ]); function render(item) { if (typeof item === "string") return item; if (Array.isArray(item)) { const tag = item[0]; const attributes = item[1] || {}; const children = item.slice(2); return `<${tag} ${Object.keys(attributes).filter((key) => !uselessKey.has(key)).map((key) => `${key}="${attributes[key]}"`).join(" ")}>${children.map((element) => render(element)).join("")}</${tag}>`; } return ""; } async function handler(ctx) { const baseUrl = "https://www.modelscope.cn"; const items = (await ofetch_default(`${baseUrl}/api/v1/dolphin/articles`, { method: "POST", body: { PageNumber: 1, PageSize: ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 18, Type: 2, Sort: "gmt_modified", Query: "", ExcludeIds: [ 1558, 1436, 881, 399, 1129 ], IsCourse: [0, 1] } })).Data.Articles.map((i) => ({ title: i.Title, description: (i.Content ? render(JSON.parse(i.Content)) : JSON.parse(i.CourseInfo).map((info) => info.Content && render(JSON.parse(info.Content))).join("")) || i.Desc, author: i.CreatedBy, link: `${baseUrl}/learn/${i.Id}`, pubDate: parseDate(i.GmtCreated, "X"), updated: parseDate(i.GmtModified, "X"), category: [...new Set([...JSON.parse(i.Domains), ...JSON.parse(i.Subjects)])], image: i.ImageUrl })); return { title: "研习社 · 魔搭社区", description: "ModelScope——汇聚各领域先进的机器学习模型,提供模型探索体验、推理、训练、部署和应用的一站式服务。在这里,共建模型开源社区,发现、学习、定制和分享心仪的模型。", image: "https://g.alicdn.com/sail-web/maas/0.8.10/favicon/128.ico", link: `${baseUrl}/learn`, item: items }; } //#endregion export { route };