rsshub
Version:
Make RSS Great Again!
76 lines (74 loc) • 2.4 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import { t as config } from "./config-MQ-7ebJ_.mjs";
import { t as ViewType } from "./types-gOySfSXJ.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./is-worker-DESPicPc.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
//#region lib/routes/fantia/user.ts
const route = {
path: "/user/:id",
categories: ["picture"],
view: ViewType.Pictures,
example: "/fantia/user/3498",
parameters: { id: "User id, can be found in user profile URL" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true
},
radar: [{ source: ["fantia.jp/fanclubs/:id"] }],
name: "User Posts",
maintainers: ["nczitzk"],
handler
};
async function handler(ctx) {
const rootUrl = "https://fantia.jp";
const userUrl = `${rootUrl}/api/v1/fanclubs/${ctx.req.param("id")}`;
const csrfToken = (await got_default({
method: "get",
url: rootUrl,
headers: { Cookie: config.fantia.cookies ?? "" }
})).data.match(/name="csrf-token" content="(.*?)"\s?\/>/)[1];
const response = await got_default({
method: "get",
url: userUrl,
headers: { Cookie: config.fantia.cookies ?? "" }
});
const list = response.data.fanclub.recent_posts.map((item) => ({
title: item.title,
link: `${rootUrl}/api/v1/posts/${item.id}`,
description: `<p>${item.comment}</p>`,
pubDate: parseDate(item.posted_at)
}));
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const contentResponse = await got_default({
method: "get",
url: item.link,
headers: {
Cookie: config.fantia.cookies ?? "",
"X-CSRF-Token": csrfToken,
Accept: "application/json, text/plain, */*",
Referer: `${rootUrl}/`,
"X-Requested-With": "XMLHttpRequest"
}
});
item.link = item.link.replace("api/v1/", "");
item.description += `<img src="${contentResponse.data.post?.thumb?.large ?? contentResponse.data.post.thumb_micro}">`;
return item;
})));
return {
title: `Fantia - ${response.data.fanclub.fanclub_name_with_creator_name}`,
link: `${rootUrl}/fanclubs/${ctx.req.param("id")}`,
item: items
};
}
//#endregion
export { route };