feat(route): Bilibili用户追漫列表 (#7758)

* bilibili追漫更新

* 文档更新

* 文档编译出错,更新
This commit is contained in:
Howard Yin
2021-06-25 15:09:41 +08:00
committed by GitHub
parent 4db1c91cfa
commit a9406ea936
3 changed files with 51 additions and 0 deletions

View File

@@ -302,6 +302,17 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
<Route author="hoilc" example="/bilibili/manga/update/26009" path="/bilibili/manga/update/:comicid" :paramsDesc="['漫画 id, 可在 URL 中找到, 支持带有`mc`前缀']"/>
### 用户追漫更新
<Route author="yindaheng98" example="/bilibili/manga/followings/26009" path="/manga/followings/:uid/:limits?" :paramsDesc="['用户 id', '抓取最近更新前多少本漫画默认为10']" selfhost="1">
::: warning 注意
用户追漫需要 b 站登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
:::
</Route>
## Dev.to
### 最高职位

View File

@@ -86,6 +86,7 @@ router.get('/bilibili/followings/article/:uid', require('./routes/bilibili/follo
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'));
router.get('/bilibili/manga/followings/:uid/:limits?', require('./routes/bilibili/manga_followings'));
router.get('/bilibili/app/:id?', require('./routes/bilibili/app'));
// bangumi

View File

@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const cache = require('./cache');
const config = require('@/config').value;
module.exports = async (ctx) => {
const uid = String(ctx.params.uid);
const name = await cache.getUsernameFromUID(ctx, uid);
const cookie = config.bilibili.cookies[uid];
if (cookie === undefined) {
throw Error('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
}
const page_size = ctx.params.limits || 10;
const link = 'https://manga.bilibili.com/account-center';
const response = await got({
method: 'POST',
url: `https://manga.bilibili.com/twirp/bookshelf.v1.Bookshelf/ListFavorite?device=pc&platform=web`,
json: { page_num: 1, page_size: page_size, order: 2, wait_free: 0 },
headers: {
Referer: link,
Cookie: cookie,
},
});
if (response.data.code === -6) {
throw Error('对应 uid 的 Bilibili 用户的 Cookie 已过期');
}
const comics = response.data.data;
ctx.state.data = {
title: `${name} 的追漫更新 - 哔哩哔哩漫画`,
link: link,
item: comics.map((item) => ({
title: `${item.title} ${item.latest_ep_short_title}`,
description: `<img src='${item.vcover}'>`,
pubDate: new Date(item.last_ep_publish_time + ' +0800'),
link: `https://manga.bilibili.com/detail/mc${item.comic_id}`,
})),
};
};