rsshub
Version:
Make RSS Great Again!
46 lines (44 loc) • 1.96 kB
JavaScript
import { t as config } from "./config-MQ-7ebJ_.mjs";
import { t as ofetch_default } from "./ofetch-DKl_Ma9g.mjs";
import { t as cache_default } from "./cache-SV6W5EPy.mjs";
import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime";
import { renderToString } from "hono/jsx/dom/server";
import { raw } from "hono/html";
//#region lib/routes/nicovideo/utils.tsx
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) => renderToString(/* @__PURE__ */ jsxs(Fragment, { children: [
embed ? /* @__PURE__ */ jsx("iframe", {
src: `https://embed.nicovideo.jp/watch/${video.id}`,
style: "top: 0; left: 0; width: 100%; height: 100%; position: absolute; border: 0;",
allowfullscreen: true
}) : /* @__PURE__ */ jsx("img", { src: video.thumbnail.nHdUrl || video.thumbnail.largeUrl || video.thumbnail.middleUrl }),
/* @__PURE__ */ jsx("br", {}),
video.shortDescription ? /* @__PURE__ */ jsx(Fragment, { children: raw(video.shortDescription) }) : null
] }));
//#endregion
export { renderVideo as i, getUserInfoById as n, getUserVideosById as r, getMylist as t };