Skip to content

Commit

Permalink
feat: add bilibili manga (DIYgod#4933)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoilc authored Jun 7, 2020
1 parent 9461e2e commit 176e0cb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/radar-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '微博',
Expand Down
4 changes: 4 additions & 0 deletions docs/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 评论
Expand Down
1 change: 1 addition & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
33 changes: 33 additions & 0 deletions lib/routes/bilibili/manga_update.js
Original file line number Diff line number Diff line change
@@ -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}`,
})),
};
};

0 comments on commit 176e0cb

Please sign in to comment.