UNPKG

rsshub

Version:
47 lines (46 loc) 1.61 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; //#region lib/routes/mit/scratch/user-projects.ts const route = { path: "/scratch/user-projects/:username", categories: ["social-media"], example: "/mit/scratch/user-projects/abee", parameters: { username: "Scratch username" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["scratch.mit.edu/users/:username/projects/"], target: "/scratch/user-projects/:username" }], name: "Scratch User Projects", maintainers: ["Skota11"], handler: async (ctx) => { const { username } = ctx.req.param(); const apiUrl = `https://api.scratch.mit.edu/users/${username}/projects/?limit=${Math.min(Number(ctx.req.query("limit")) || 40, 40)}`; const items = (await rofetch(apiUrl)).map((item) => { const descriptionText = [item.instructions ? `Instructions:<br>${item.instructions}` : "", item.description ? `Notes and Credits:<br>${item.description}` : ""].filter(Boolean).join("<br><br>").replaceAll("\n", "<br>"); return { title: item.title, description: descriptionText, pubDate: parseDate(item.history.shared), link: `https://scratch.mit.edu/projects/${item.id}/`, guid: `scratch-project-${item.id}`, image: item.image, author: username }; }); return { title: `Scratch User Projects - ${username}`, link: `https://scratch.mit.edu/users/${username}/projects/`, item: items }; } }; //#endregion export { route };