rsshub
Version:
Make RSS Great Again!
69 lines (67 loc) • 1.98 kB
JavaScript
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 "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import "./timezone-D8cuwzTY.mjs";
import { a as notesUrl, s as ssoUrl } from "./utils-CBTVNQEo.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/qoo-app/notes/note.ts
init_esm_shims();
const route = {
path: "/notes/:lang?/note/:id",
categories: ["anime"],
example: "/qoo-app/notes/en/note/2329113",
parameters: {
lang: "Language, see the table above, empty means `中文`",
id: "Note ID, can be found in URL"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "Note Comments",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const api = `${ssoUrl}/api/v1/comments`;
const link = `${notesUrl}/note/${id}`;
const { data: response } = await got_default(link);
const $ = load(response);
const { data } = await got_default(api, { searchParams: {
sort: "newest",
for: "web",
limit: ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 100,
type: "note",
object_id: id
} });
const items = data.data.map((item) => ({
title: item.content,
description: art(path.join(__dirname, "templates/note-4d6e8c65.art"), {
content: item.content,
picture: item.picture
}),
pubDate: parseDate(item.created_timestamp),
author: item.user.name,
guid: `qoo-app:notes:note:${id}:${item.id}`
}));
return {
title: $("head title").text(),
link,
language: $("html").attr("lang"),
item: items
};
}
//#endregion
export { route };