UNPKG

rsshub

Version:
75 lines (73 loc) 2.71 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 markdownit from "markdown-it"; //#region lib/routes/modelscope/datasets.ts init_esm_shims(); const md = markdownit({ html: true, linkify: true }); const route = { path: "/datasets", categories: ["programming"], example: "/modelscope/datasets", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["modelscope.cn/datasets"] }], name: "数据集", maintainers: ["TonyRL"], handler, url: "modelscope.cn/datasets" }; async function handler(ctx) { const baseUrl = "https://modelscope.cn"; const link = `${baseUrl}/datasets`; const { data } = await got_default(`${baseUrl}/api/v1/dolphin/datasets`, { searchParams: { PageSize: ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 36, PageNumber: 1, Target: "", Sort: "gmt_modified" } }); const datasets = data.Data.map((dataset) => ({ title: dataset.ChineseName, description: dataset.Description, author: dataset.CreatedBy, link: `${link}/${dataset.Namespace}/${dataset.Name}`, pubDate: parseDate(dataset.GmtCreate, "X"), category: dataset.UserDefineTags.split(","), slug: `/${dataset.Namespace}/${dataset.Name}` })); return { title: "数据集首页 · 魔搭社区", description: "ModelScope——汇聚各领域先进的机器学习模型,提供模型探索体验、推理、训练、部署和应用的一站式服务。在这里,共建模型开源社区,发现、学习、定制和分享心仪的模型。", image: "https://g.alicdn.com/sail-web/maas/0.8.10/favicon/128.ico", link, item: await Promise.all(datasets.map((item) => cache_default.tryGet(item.link, async () => { const { data: data$1 } = await got_default(`${baseUrl}/api/v1/datasets${item.slug}`); const content = data$1.Data.ReadmeContent.replaceAll(/img src="(?!http)(.*?)"/g, `img src="${baseUrl}/api/v1/datasets${item.slug}/repo?Revision=master&FilePath=$1&View=true"`); item.description = art(path.join(__dirname, "templates/desc-9a28dd77.art"), { description: item.description, md: md.render(content) }); return item; }))) }; } //#endregion export { route };