rsshub
Version:
Make RSS Great Again!
42 lines (40 loc) • 1.53 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 ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import path from "node:path";
//#region lib/routes/nicovideo/utils.ts
init_esm_shims();
const getUserInfoById = (id) => cache_default.tryGet(`nicovideo:user:${id}`, () => ofetch_default(`https://embed.nicovideo.jp/users/${id}`));
const getUserVideosById = (id) => cache_default.tryGet(`nicovideo:user:${id}:videos`, async () => {
const { data } = await ofetch_default(`https://nvapi.nicovideo.jp/v3/users/${id}/videos`, {
headers: { "X-Frontend-Id": "6" },
query: {
sortKey: "registeredAt",
sortOrder: "desc",
sensitiveContents: "mask",
pageSize: 100,
page: 1
}
});
return data.items;
}, config.cache.routeExpire, false);
const getMylist = (id) => cache_default.tryGet(`nicovideo:mylist:${id}`, async () => {
const { data } = await ofetch_default(`https://nvapi.nicovideo.jp/v2/mylists/${id}`, {
headers: { "X-Frontend-Id": "6" },
query: {
sortKey: "addedAt",
sortOrder: "desc",
pageSize: 500,
page: 1
}
});
return data.mylist;
}, config.cache.routeExpire, false);
const renderVideo = (video, embed) => art(path.join(__dirname, "templates/video-3a0bdb3a.art"), {
video,
embed
});
//#endregion
export { renderVideo as i, getUserInfoById as n, getUserVideosById as r, getMylist as t };