rsshub
Version:
Make RSS Great Again!
46 lines (45 loc) • 1.59 kB
JavaScript
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs";
import { t as parseDate } from "./parse-date-Cr0wQjV_.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 items = (await rofetch(`https://api.scratch.mit.edu/users/${username}/projects/?limit=${Math.min(Number(ctx.req.query("limit")) || 40, 40)}`)).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 };