* feat(route/bilibili): refactor bangumi with ofetch and art-template * feat(route/bilibili): refactor bilibili-recommend with art-template * feat(route/bilibili): refactor coin with art-template * feat(route/bilibili): refactor fav with art-template * feat(route/bilibili): refactor like with art-template * feat(route/bilibili): refactor page with art-template * feat(route/bilibili): refactor partion-ranking with art-template * feat(route/bilibili): refactor partion with art-template * feat(route/bilibili): refactor popular with art-template * feat(route/bilibili): refactor ranking with art-template * feat(route/bilibili): refactor user-channel with art-template * feat(route/bilibili): refactor user-collection with art-template * feat(route/bilibili): refactor user-fav with art-template * feat(route/bilibili): refactor weekly-recommend with art-template * feat(route/bilibili): refactor dynamic with art-template * feat(route/bilibili): refactor followings-dynamic with art-template * feat(route/bilibili): refactor followings-video with art-template * feat(route/bilibili): refactor video-all with art-template * feat(route/bilibili): refactor video with art-template * feat(route/bilibili): refactor vsearch with art-template * feat(route/bilibili): refactor watchlater with art-template * feat(route/bilibili): remove iframe * fix(route/bilibili): __dirname * docs(route/bilibili): add documents. * feat(route/bilibili): use https cover * style(bilibili): camelCase * style(bilibili): keep ordering * fix(bilibili): use html5mobileplayer.html ---------
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import utils from './utils';
|
|
|
|
export const route: Route = {
|
|
path: '/video/page/:bvid/:embed?',
|
|
categories: ['social-media'],
|
|
example: '/bilibili/video/page/BV1i7411M7N9',
|
|
parameters: { bvid: '可在视频页 URL 中找到', embed: '默认为开启内嵌视频, 任意值为关闭' },
|
|
features: {
|
|
requireConfig: false,
|
|
requirePuppeteer: false,
|
|
antiCrawler: false,
|
|
supportBT: false,
|
|
supportPodcast: false,
|
|
supportScihub: false,
|
|
},
|
|
name: '视频选集列表',
|
|
maintainers: ['sxzz'],
|
|
handler,
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
let bvid = ctx.req.param('bvid');
|
|
let aid;
|
|
if (!bvid.startsWith('BV')) {
|
|
aid = bvid;
|
|
bvid = null;
|
|
}
|
|
const embed = !ctx.req.param('embed');
|
|
const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`;
|
|
const response = await got({
|
|
method: 'get',
|
|
url: `https://api.bilibili.com/x/web-interface/view?${bvid ? `bvid=${bvid}` : `aid=${aid}`}`,
|
|
headers: {
|
|
Referer: link,
|
|
},
|
|
});
|
|
|
|
const respdata = response.data.data;
|
|
const { title: name, pages: data } = response.data.data;
|
|
|
|
return {
|
|
title: `视频 ${name} 的选集列表`,
|
|
link,
|
|
description: `视频 ${name} 的视频选集列表`,
|
|
item: data
|
|
.sort((a, b) => b.page - a.page)
|
|
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10)
|
|
.map((item) => ({
|
|
title: item.part,
|
|
description: utils.renderUGCDescription(embed, respdata.pic, `${item.part} - ${name}`, respdata.aid, item.cid, respdata.bvid),
|
|
link: `${link}?p=${item.page}`,
|
|
})),
|
|
};
|
|
}
|