rsshub
Version:
Make RSS Great Again!
72 lines (70 loc) • 2.44 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.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 "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { a as getBuildId, c as parseList, i as getBParam, n as baseUrl, o as getGToken, s as parseItem, t as apiUrl } from "./utils-B2Ngnh7l.mjs";
//#region lib/routes/followin/tag.ts
const route = {
path: "/tag/:tagId/:lang?",
categories: ["finance"],
example: "/followin/tag/177008",
parameters: {
tagId: "Tag ID, can be found in URL",
lang: "Language, see table above, `en` by default"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["followin.io/:lang/tag/:tagId", "followin.io/tag/:tagId"] }],
name: "Tag",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const { tagId, lang = "en" } = ctx.req.param();
const { limit = 20 } = ctx.req.query();
const buildId = await getBuildId(cache_default.tryGet);
const tagInfo = await cache_default.tryGet(`followin:tag:${tagId}:${lang}`, async () => {
const { data: response } = await got_default(`${baseUrl}/_next/data/${buildId}/${lang}/tag/${tagId}.json`);
const { queries } = response.pageProps.dehydratedState;
const { base_info: tagInfo$1 } = queries.find((q) => q.queryKey[0] === "/tag/info/v2").state.data;
return tagInfo$1;
});
const gToken = await getGToken(cache_default.tryGet);
const bParam = getBParam(lang);
const { data: tagResponse } = await got_default.post(`${apiUrl}/feed/list/tag`, {
headers: {
"x-bparam": JSON.stringify(bParam),
"x-gtoken": gToken
},
json: {
count: limit,
id: Number.parseInt(tagId),
type: "tag_discussion_feed"
}
});
if (tagResponse.code !== 2e3) throw new Error(tagResponse.msg);
const list = parseList(tagResponse.data.list.slice(0, limit), lang, buildId);
const items = await Promise.all(list.map((item) => parseItem(item, cache_default.tryGet)));
return {
title: `${tagInfo.name} - Followin`,
description: tagInfo.description,
link: `${baseUrl}/${lang}/tag/${tagId}`,
image: tagInfo.logo,
language: lang,
item: items
};
}
//#endregion
export { route };