UNPKG

rsshub

Version:
46 lines (45 loc) 1.74 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; //#region lib/routes/shanbay/checkin.ts const route = { path: "/checkin/:id", categories: ["study"], example: "/shanbay/checkin/ddwej", parameters: { id: "用户 id" }, name: "用户打卡", maintainers: ["DIYgod"], handler }; async function handler(ctx) { const { id } = ctx.req.param(); const username = await cache_default.tryGet(`shanbayuser${id}`, async () => { const response = await rofetch(`https://web.shanbay.com/web/checkin/achievement?user_id=${id}`); return load(response)("#user-info-area .name").text(); }); const link = `https://web.shanbay.com/web/wechat/calendar/?user_id=${id}`; const response = await rofetch(`https://apiv3.shanbay.com/uc/checkin/logs?page=1&user_id=${id}`, { headers: { Referer: link } }); return { title: `${username} 的扇贝打卡`, link, item: response.objects.map((item) => { const action = item.tasks.toSorted((a, b) => b.used_time - a.used_time).map((task) => { const minute = Math.floor(task.used_time / 60); const second = task.used_time - minute * 60; return `${task.operation}${task.num} ${task.unit}${task.name},学习时间 ${minute}${second} 秒`; }).join(";"); const pubDate = timezone(parseDate(item.date), 8); return { title: `${username} 的第 ${item.checkin_days_num} 天扇贝打卡`, pubDate, guid: item.id + (pubDate.getTime() >= 15967296e5 ? action : ""), description: action, link }; }) }; } //#endregion export { route };