UNPKG

rsshub

Version:
57 lines (55 loc) 2.02 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { n as fetchFriends, r as getPlurk, t as baseUrl } from "./utils-D-b2Mbgt.mjs"; import { load } from "cheerio"; //#region lib/routes/plurk/topic.ts const route = { path: "/topic/:topic", categories: ["social-media"], view: ViewType.SocialMedia, example: "/plurk/topic/standwithukraine", parameters: { topic: "Topic ID, can be found in URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["plurk.com/topic/:topic"] }], name: "Topic", maintainers: ["TonyRL"], handler }; async function handler(ctx) { const topic = ctx.req.param("topic"); const { data: pageResponse } = await got_default(`${baseUrl}/topic/${topic}`); const { data: apiResponse } = await got_default(`${baseUrl}/topic/getPlurks`, { searchParams: { topic, offset: 0, limit: ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 30 } }); const $ = load(pageResponse); delete apiResponse.pids; delete apiResponse.count; const names = await fetchFriends(Object.values(apiResponse).map((item) => item.user_id)); const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, cache_default.tryGet))); return { title: $("head title").text(), description: $("meta[property=og:description]").attr("content"), image: $("meta[property=og:image]").attr("content") || $("meta[name=msapplication-TileImage]").attr("content"), link: `${baseUrl}/topic/${topic}`, item: items }; } //#endregion export { route };