From a48ac252b7d786bd896329ef46e9d89eaa03a71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Tue, 19 Feb 2019 15:10:01 +0800 Subject: [PATCH] add bilibili video list (#1556) --- docs/README.md | 3 +++ lib/router.js | 1 + lib/routes/bilibili/page.js | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 lib/routes/bilibili/page.js diff --git a/docs/README.md b/docs/README.md index 7d241a88e..8186eae99 100644 --- a/docs/README.md +++ b/docs/README.md @@ -149,6 +149,7 @@ RSSHub 提供下列 API 接口: "/bilibili/partion/:tid", "/bilibili/partion/ranking/:tid/:days?", "/bilibili/bangumi/:seasonid", + "/bilibili/video/page/:aid", "/bilibili/video/reply/:aid", "/bilibili/link/news/:product", "/bilibili/live/room/:roomID", @@ -295,6 +296,8 @@ RSSHub 提供下列 API 接口: + + diff --git a/lib/router.js b/lib/router.js index dca04af4a..3fb48fc98 100644 --- a/lib/router.js +++ b/lib/router.js @@ -104,6 +104,7 @@ router.get('/bilibili/partion/:tid', require('./routes/bilibili/partion')); router.get('/bilibili/partion/ranking/:tid/:days?', require('./routes/bilibili/partion-ranking')); router.get('/bilibili/bangumi/:seasonid', require('./routes/bilibili/bangumi')); // 弃用 router.get('/bilibili/bangumi/media/:mediaid', require('./routes/bilibili/bangumi')); +router.get('/bilibili/video/page/:aid', require('./routes/bilibili/page')); router.get('/bilibili/video/reply/:aid', require('./routes/bilibili/reply')); router.get('/bilibili/video/danmaku/:aid/:pid?', require('./routes/bilibili/danmaku')); router.get('/bilibili/link/news/:product', require('./routes/bilibili/linkNews')); diff --git a/lib/routes/bilibili/page.js b/lib/routes/bilibili/page.js new file mode 100644 index 000000000..b9fc9c8e1 --- /dev/null +++ b/lib/routes/bilibili/page.js @@ -0,0 +1,26 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const aid = ctx.params.aid; + const response = await axios({ + method: 'get', + url: `https://api.bilibili.com/x/web-interface/view?aid=${aid}`, + headers: { + Referer: `https://www.bilibili.com/video/av${aid}`, + }, + }); + + const { title: name, pages: data } = response.data.data; + + ctx.state.data = { + title: `视频 ${name} 的选集列表`, + link: `https://www.bilibili.com/video/av${aid}`, + description: `视频 ${name} 的视频选集列表`, + item: data.map((item) => ({ + title: item.part, + description: `${item.part} - ${name}`, + pubDate: new Date().toUTCString(), + link: `https://www.bilibili.com/video/av${aid}?p=${item.page}`, + })), + }; +};