rsshub
Version:
Make RSS Great Again!
68 lines (66 loc) • 2.15 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./md5-C8GRvctM.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./render-BQo6B4tL.mjs";
import { r as utils_default } from "./utils-XRYoJEu4.mjs";
//#region lib/routes/bilibili/bangumi.ts
const route = {
path: "/bangumi/media/:mediaid/:embed?",
name: "番剧",
parameters: {
mediaid: "番剧媒体 id, 番剧主页 URL 中获取",
embed: "默认为开启内嵌视频, 任意值为关闭"
},
example: "/bilibili/bangumi/media/9192",
categories: ["social-media"],
view: ViewType.Videos,
maintainers: ["DIYgod", "nuomi1"],
handler,
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportRadar: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
}
};
async function handler(ctx) {
const mediaId = ctx.req.param("mediaid");
const embed = !ctx.req.param("embed");
const mediaData = await utils_default.getBangumi(mediaId, cache_default);
const seasonId = String(mediaData.season_id);
const seasonData = await utils_default.getBangumiItems(seasonId, cache_default);
const episodes = [];
const getEpisode = (item, title) => ({
title,
description: utils_default.renderOGVDescription(embed, item.cover, item.long_title, seasonId, String(item.id)),
link: item.share_url,
image: item.cover.replace("http://", "https://"),
language: "zh-cn"
});
for (const item of seasonData.main_section.episodes) {
const episode = getEpisode(item, `第${item.title}话 ${item.long_title}`);
episodes.push(episode);
}
for (const section of seasonData.section) for (const item of section.episodes) {
const episode = getEpisode(item, `${item.title} ${item.long_title}`);
episodes.push(episode);
}
return {
title: mediaData.title,
description: mediaData.evaluate,
link: mediaData.share_url,
item: episodes,
image: mediaData.cover.replace("http://", "https://"),
language: "zh-cn"
};
}
//#endregion
export { route };