rsshub
Version:
Make RSS Great Again!
86 lines (84 loc) • 2.48 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import { t as logger_default } from "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import "./proxy-Db7uGcYb.mjs";
import "./got-KxxWdaxq.mjs";
import "./invalid-parameter-rr4AgGpp.mjs";
import "./config-not-found-Dyp3RlZZ.mjs";
import "./puppeteer-DGmvuGvT.mjs";
import "./readable-social-DoIL4WB3.mjs";
import { t as api_default } from "./api-DtVrjNN4.mjs";
import { t as utils_default } from "./utils-BmkxbUEd.mjs";
//#region lib/routes/twitter/media.ts
const route = {
path: "/media/:id/:routeParams?",
categories: ["social-media"],
view: ViewType.Pictures,
example: "/twitter/media/_RSSHub",
parameters: {
id: "username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`",
routeParams: "extra parameters, see the table above."
},
features: {
requireConfig: [
{
name: "TWITTER_USERNAME",
description: "Please see above for details."
},
{
name: "TWITTER_PASSWORD",
description: "Please see above for details."
},
{
name: "TWITTER_AUTH_TOKEN",
description: "Please see above for details."
}
],
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "User media",
maintainers: [
"DIYgod",
"yindaheng98",
"Rongronggg9"
],
handler,
radar: [{
source: ["x.com/:id/media"],
target: "/media/:id"
}]
};
async function handler(ctx) {
const id = ctx.req.param("id");
const { count } = utils_default.parseRouteParams(ctx.req.param("routeParams"));
const params = count ? { count } : {};
await api_default.init();
const userInfo = await api_default.getUser(id);
let data;
try {
data = await api_default.getUserMedia(id, params);
} catch (error) {
logger_default.error(error);
}
const profileImageUrl = userInfo?.profile_image_url || userInfo?.profile_image_url_https;
return {
title: `Twitter @${userInfo?.name}`,
link: `https://x.com/${userInfo?.screen_name}/media`,
image: profileImageUrl.replace(/_normal.jpg$/, ".jpg"),
description: userInfo?.description,
item: data && utils_default.ProcessFeed(ctx, { data }),
allowEmpty: true
};
}
//#endregion
export { route };