rsshub
Version:
Make RSS Great Again!
72 lines (69 loc) • 2.5 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/500px/utils.ts
init_esm_shims();
const baseUrl = "https://500px.com.cn";
const headers = {
"x-500px-client-info": "eyJhbm9ueW1vdXNJZCI6IiIsImxhdGl0dWRlIjpudWxsLCJsb25naXR1ZGUiOm51bGwsIm1hbnVmYWN0dXJlciI6IiIsInByb3ZpbmNlIjoiIiwiYXJlYSI6IiIsImNpdHkiOiIifQ==",
"X-Tingyun-Id": `Fm3hXcTiLT8;r=${Date.now() % 1e8}`
};
const getTribeDetail = (id) => cache_default.tryGet(`500px:tribeDetail:${id}`, async () => {
return (await ofetch_default(`${baseUrl}/community/tribe/tribeDetail`, {
headers: { ...headers },
query: { tribeId: id }
})).data;
}, config.cache.routeExpire, false);
const getTribeSets = (id, limit) => cache_default.tryGet(`500px:tribeSets:${id}`, async () => {
return (await ofetch_default(`${baseUrl}/community/tribe/getTribeSetsV2`, {
headers: { ...headers },
query: {
tribeId: id,
privacy: 1,
page: 1,
size: limit,
type: "json"
}
})).data;
}, config.cache.routeExpire, false);
//#endregion
//#region lib/routes/500px/tribe-set.ts
const route = {
path: "/tribe/set/:id",
categories: ["picture"],
view: ViewType.Pictures,
example: "/500px/tribe/set/f5de0b8aa6d54ec486f5e79616418001",
parameters: { id: "部落 ID" },
name: "部落影集",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const limit = Number.parseInt(ctx.req.query("limit")) || 100;
const { tribe } = await getTribeDetail(id);
const items = (await getTribeSets(id, limit)).map((item) => ({
title: item.title,
description: art(path.join(__dirname, "templates/tribeSet-3e687c05.art"), { item }),
author: item.uploaderInfo.nickName,
pubDate: parseDate(item.createdTime, "x"),
link: `${baseUrl}/community/set/${item.id}/details`
}));
return {
title: tribe.name,
description: `${tribe.watchword} - ${tribe.introduce}`,
link: `${baseUrl}/page/tribe/detail?tribeId=${id}&pagev=set`,
image: tribe.avatar.a1,
item: items
};
}
//#endregion
export { route };