UNPKG

rsshub

Version:
39 lines (38 loc) 1.41 kB
import { t as config } from "./config-CCmw1BNE.mjs"; import { t as ConfigNotFoundError } from "./config-not-found-fQ5mxvDU.mjs"; import { n as getAppClient } from "./api-DAI6sKK3.mjs"; //#region lib/routes/twitter/trends.ts const route = { path: "/trends/:woeid?", categories: ["social-media"], example: "/twitter/trends/23424856", parameters: { woeid: "Yahoo! Where On Earth ID. default to woeid=1 (World Wide)" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "Trends", maintainers: ["sakamossan"], handler }; async function handler(ctx) { if (!config.twitter || !config.twitter.consumerKey || !config.twitter.consumerSecret) throw new ConfigNotFoundError("Twitter RSS is disabled due to the lack of <a href=\"https://docs.rsshub.app/deploy/config#route-specific-configurations\">relevant config</a>"); const woeid = ctx.req.param("woeid") ?? 1; const data = await (await getAppClient()).v1.get("trends/place.json", { id: woeid }); const [{ trends }] = data; return { title: `Twitter Trends on ${data[0].locations[0].name}`, link: "https://x.com/i/trends", item: trends.filter((t) => !t.promoted_content).map((t) => ({ title: t.name, link: t.url, description: t.name + (t.tweet_volume ? ` (${t.tweet_volume})` : "") })) }; } //#endregion export { route };