rsshub
Version:
Make RSS Great Again!
41 lines (39 loc) • 1.47 kB
JavaScript
import { t as config } from "./config-MQ-7ebJ_.mjs";
import "./parse-date-r5WDWHno.mjs";
import { t as config_not_found_default } from "./config-not-found-zoFMPvbz.mjs";
import { t as utils_default } from "./utils-CH6LJqJI.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.consumer_key || !config.twitter.consumer_secret) throw new config_not_found_default("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 utils_default.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 };