UNPKG

rsshub

Version:
77 lines (75 loc) 2.23 kB
import { n as init_esm_shims, t as __dirname } from "./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 { 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 path from "node:path"; //#region lib/routes/gettr/user.ts init_esm_shims(); const actionMap = { pub_pst: "Published a post: ", shares_cm: "Shared a comment: ", shares_pst: "Shared a post: " }; const route = { path: "/user/:id", categories: ["social-media"], view: ViewType.SocialMedia, example: "/gettr/user/jasonmillerindc", parameters: { id: "User id" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["gettr.com/user/:id"] }], name: "User timeline", maintainers: ["TonyRL"], handler }; async function handler(ctx) { const baseUrl = "https://gettr.com"; const apiHost = "https://api.gettr.com"; const mediaHost = "https://media.gettr.com"; const id = ctx.req.param("id"); const { data: posts } = await got_default(`${apiHost}/u/user/${id}/posts`, { searchParams: { offset: 0, max: 20, dir: "fwd", incl: "posts|stats|userinfo|shared|liked|pvotes", fp: "f_uo" } }); const userInfo = posts.result.aux.uinf[id]; const items = posts.result.data.list.map((post) => { const title = posts.result.aux.post[post.activity.pstid].txt; const description = art(path.join(__dirname, "templates/post-6f36fbe0.art"), { post: posts.result.aux.post[post.activity.pstid], mediaHost }); return { title: `${actionMap[post.action]} ${title}`, description, pubDate: parseDate(post.cdate), updated: parseDate(post.udate), link: `${baseUrl}/post/${post.activity.pstid}` }; }); return { title: `${userInfo.nickname} on Gettr`, description: userInfo.dsc, link: `${baseUrl}/user/${id}`, image: `${mediaHost}/${userInfo.ico}`, language: "en", item: items }; } //#endregion export { route };