rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.71 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.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 () => {
return load(await rofetch(`https://web.shanbay.com/web/checkin/achievement?user_id=${id}`))("#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 };