feat: add bilibili manga (#4933)

This commit is contained in:
hoilc
2020-06-07 22:57:48 +08:00
committed by GitHub
parent 9461e2eb5c
commit 176e0cbd66
4 changed files with 46 additions and 0 deletions

View File

@@ -43,6 +43,14 @@
target: '/bilibili/user/video/:uid',
},
],
manga: [
{
title: '漫画更新',
docs: 'https://docs.rsshub.app/social-media.html#bilibili-man-hua-geng-xin',
source: '/detail/:comicid',
target: '/bilibili/manga/update/:comicid',
},
],
},
'weibo.com': {
_name: '微博',

View File

@@ -258,6 +258,10 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
<Route author="ttttmr" example="/bilibili/weekly" path="/bilibili/weekly/:disableEmbed?" :paramsDesc="['默认为开启内嵌视频, 任意值为关闭']"/>
### 漫画更新
<Route author="hoilc" example="/bilibili/manga/update/26009" path="/bilibili/manga/update/:comicid" :paramsDesc="['漫画 id, 可在 URL 中找到, 支持带有`mc`前缀']"/>
## Disqus
### 评论

View File

@@ -75,6 +75,7 @@ router.get('/bilibili/followings/video/:uid/:disableEmbed?', require('./routes/b
router.get('/bilibili/followings/article/:uid', require('./routes/bilibili/followings_article'));
router.get('/bilibili/readlist/:listid', require('./routes/bilibili/readlist'));
router.get('/bilibili/weekly', require('./routes/bilibili/weekly_recommend'));
router.get('/bilibili/manga/update/:comicid', require('./routes/bilibili/manga_update'));
// bangumi
router.get('/bangumi/calendar/today', require('./routes/bangumi/calendar/today'));

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const comic_id = ctx.params.comicid.startsWith('mc') ? ctx.params.comicid.replace('mc', '') : ctx.params.comicid;
const link = `https://manga.bilibili.com/detail/mc${comic_id}`;
const response = await got({
method: 'POST',
url: `https://manga.bilibili.com/twirp/comic.v2.Comic/ComicDetail?device=pc&platform=web`,
json: {
comic_id: Number(comic_id),
},
headers: {
Referer: link,
},
});
const data = response.data.data;
const author = data.author_name.join(', ');
ctx.state.data = {
title: `${data.title} - 哔哩哔哩漫画`,
link: link,
image: data.vertical_cover,
description: data.classic_lines,
item: data.ep_list.slice(0, 20).map((item) => ({
title: item.short_title === item.title ? item.short_title : `${item.short_title} ${item.title}`,
author: author,
description: `<img src="${item.cover}">`,
pubDate: new Date(item.pub_time + ' +0800'),
link: `https://manga.bilibili.com/mc${comic_id}/${item.id}`,
})),
};
};