UNPKG

rsshub

Version:
41 lines (39 loc) 1.53 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import "./md5-C8GRvctM.mjs"; import "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import "./render-BQo6B4tL.mjs"; import "./proxy-Db7uGcYb.mjs"; import "./got-KxxWdaxq.mjs"; import "./puppeteer-DGmvuGvT.mjs"; import "./utils-XRYoJEu4.mjs"; import { t as cache_default } from "./cache-COvn8_4R.mjs"; //#region lib/routes/bilibili/check-cookie.ts const apiRoute = { path: "/check-cookie", description: "检查 bilibili cookie 是否有效", maintainers: ["DIYgod"], handler }; async function handler() { const cookie = await cache_default.getCookie(); if (!cookie) return { code: -1 }; const response = await ofetch_default(`https://api.bilibili.com/x/web-interface/nav`, { headers: { Referer: `https://space.bilibili.com/1/`, Cookie: cookie } }); const isResponseValid = response.code === 0 && !!response.data.mid; const subtitleResponse = await ofetch_default(`https://api.bilibili.com/x/player/wbi/v2?bvid=BV1iU411o7R2&cid=1550543560`, { headers: { Referer: `https://www.bilibili.com/video/BV1iU411o7R2`, Cookie: cookie } }); const subtitles = subtitleResponse?.data?.subtitle?.subtitles || []; const isSubtitleResponseValid = subtitleResponse?.data?.permission !== "0" && subtitles.length > 0; return { code: isResponseValid && isSubtitleResponseValid ? 0 : -1 }; } //#endregion export { apiRoute };