Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): 新增 米游社 路由 #9404

Merged
merged 37 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b17cd3a
feat: 优化B站动态转发内容中的图片和视频
CaoMeiYouRen Apr 28, 2020
8a91b7b
style: 修复格式错误
CaoMeiYouRen Apr 28, 2020
ef4a3da
fix: 修复 B站动态转发多图的图片缺失
CaoMeiYouRen Apr 28, 2020
22638df
fix: 解决冲突
CaoMeiYouRen Apr 28, 2020
895d3e3
style: 整理代码格式
CaoMeiYouRen Apr 28, 2020
67884cb
style: 整理代码格式
CaoMeiYouRen Apr 28, 2020
dea1124
fix: 修复B站动态转发视频缺失标题
CaoMeiYouRen Apr 29, 2020
56dd032
fix: 移除了部分不必要的代码
CaoMeiYouRen Apr 30, 2020
7ff1b63
Merge branch 'master' of gitee.com:caomeiyouren/RSSHub2
CaoMeiYouRen Apr 30, 2020
fd05f99
fix: 修复b站动态中转发直播间动态出现undefined;整理部分代码
CaoMeiYouRen Apr 30, 2020
90e2d0a
style: 整理代码格式
CaoMeiYouRen Apr 30, 2020
8df5346
合并冲突
CaoMeiYouRen Apr 30, 2020
670e15f
fix: 补充b站动态中转发活动的信息
CaoMeiYouRen May 1, 2020
2fde06c
Merge branch 'master' of gitee.com:caomeiyouren/RSSHub2
CaoMeiYouRen May 1, 2020
2de02c8
fix: 修正代码格式
CaoMeiYouRen May 1, 2020
72ba788
fix: b站动态转发专题页缺少标题;整理部分代码
CaoMeiYouRen May 1, 2020
1d45198
fix: 修复图片错误
CaoMeiYouRen May 1, 2020
5ade389
fix: 修复专栏封面缺失的bug;增加B站动态格式总结
CaoMeiYouRen May 5, 2020
0ba3619
merge: 合并冲突
CaoMeiYouRen May 5, 2020
26cd8d9
style:修复格式问题
CaoMeiYouRen May 5, 2020
0fc17cd
Merge branch 'master' of github.com:CaoMeiYouRen/RSSHub; branch 'mast…
CaoMeiYouRen May 29, 2020
68e91b1
fix: 修复/robots.txt路由
CaoMeiYouRen May 29, 2020
91a4d0d
fix
CaoMeiYouRen Jun 17, 2020
ff2671a
Merge branch 'master' of https://github.com/DIYgod/RSSHub
CaoMeiYouRen Jun 23, 2020
4db69c5
Merge branch 'master' of https://github.com/DIYgod/RSSHub
CaoMeiYouRen Nov 7, 2020
19ee97f
chore: 合并冲突
CaoMeiYouRen Nov 7, 2020
f154d2a
fix
CaoMeiYouRen Nov 7, 2020
0db50e2
fix
CaoMeiYouRen Nov 7, 2020
91b7b48
feat: 优化B站动态url
CaoMeiYouRen Nov 7, 2020
94f6535
fix: 改 \n 为<br>
CaoMeiYouRen Nov 7, 2020
79357cf
chore: 更新 npm registry
CaoMeiYouRen Feb 15, 2022
b3e035b
Merge branch 'master' of github.com:CaoMeiYouRen/RSSHub
CaoMeiYouRen Feb 15, 2022
1c89814
Merge branch 'master' of gitee.com:caomeiyouren/RSSHub4
CaoMeiYouRen Mar 28, 2022
2b5ee1b
feat: 完成 米游社路由和文档的编写
CaoMeiYouRen Mar 28, 2022
cb5a514
fix: 修复 @vuepress/shared-utils 在 yarn.lock 的缺失
CaoMeiYouRen Mar 28, 2022
d77b4d3
chore: exact match
TonyRL Mar 29, 2022
c502a22
fix: parseDate
TonyRL Mar 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,24 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`

</Route>

### 米游社 - 官方公告

<Route author="CaoMeiYouRen" example="/mihoyo/bbs/official/2/3/20/" path="/bbs/official/:gids/:type?/:page_size?/:last_id?" :paramsDesc="['游戏id','公告类型,默认为 2(即 活动)','分页大小,默认为 20 ','跳过的公告数,例如指定为 40 就是从第 40 条公告开始,可用于分页']" radar="1">

游戏 id

| 崩坏三 | 原神 | 崩坏二 | 未定事件簿 | 星穹铁道 |
| --- | -- | --- | ----- | ---- |
| 1 | 2 | 3 | 4 | 6 |

公告类型

| 公告 | 活动 | 资讯 |
| -- | -- | -- |
| 1 | 2 | 3 |

</Route>

## 明日方舟

### 游戏公告与新闻
Expand Down
62 changes: 62 additions & 0 deletions lib/v2/mihoyo/bbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
// 游戏id
const GITS_MAP = {
1: '崩坏三',
2: '原神',
3: '崩坏二',
4: '未定事件簿',
6: '崩坏:星穹铁道',
};

// 公告类型
const TYPE_MAP = {
1: '公告',
2: '活动',
3: '资讯',
};

const renderDescription = (description, images) => art(path.join(__dirname, 'templates/description.art'), { description, images });

module.exports = async (ctx) => {
const { gids, type = '2', page_size = '20', last_id = '' } = ctx.params;
const query = new URLSearchParams({
gids,
type,
page_size,
last_id,
}).toString();
const url = `https://bbs-api.mihoyo.com/post/wapi/getNewsList?${query}`;
const response = await got({
method: 'get',
url,
});
const list = response?.data?.data?.list;
if (!list) {
throw new Error('未获取到数据!');
}
const title = `米游社 - ${GITS_MAP[gids] || ''} - ${TYPE_MAP[type] || ''}`;
const items = list.map((e) => {
const author = e.user.nickname;
const title = e.post.subject;
const link = `https://bbs.mihoyo.com/ys/article/${e.post.post_id}`;
const description = renderDescription(e.post.content, e.post.images);
const pubDate = parseDate(e.post.created_at * 1000);
return {
author,
title,
link,
description,
pubDate,
};
});
const data = {
title,
link: url,
item: items,
};

ctx.state.data = data;
};
3 changes: 3 additions & 0 deletions lib/v2/mihoyo/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'],
};
31 changes: 31 additions & 0 deletions lib/v2/mihoyo/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
'mihoyo.com': {
_name: '米游社v2',
bbs: [
{
title: '米游社 - 官方公告',
docs: 'https://docs.rsshub.app/game.html#mi-ha-you-mi-you-she-guan-fang-gong-gao',
// source: ['/ys/home/28', '/bh3/home/6', '/bh2/home/31', '/wd/home/33', '/sr/home/53'],
source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53'],
target: (params, url) => {
const GITS_MAP = {
bh3: 1, // '崩坏三',
ys: 2, // '原神',
bh2: 3, // '崩坏二',
wd: 4, // '未定事件簿',
sr: 6, // '崩坏:星穹铁道',
};
const { game } = params;
const gids = GITS_MAP[game];
if (!gids) {
return '';
}
const { type = '2' } = new URL(url).searchParams;
const page_size = '20';
const last_id = '';
return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`;
},
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/mihoyo/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs'));
};
6 changes: 6 additions & 0 deletions lib/v2/mihoyo/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ description }}
{{if images}}
{{each images}}
<img src="{{ $value }}">
{{/each}}
{{/if}}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@vuepress/plugin-back-to-top": "1.9.7",
"@vuepress/plugin-google-analytics": "1.9.7",
"@vuepress/plugin-pwa": "1.9.7",
"@vuepress/shared-utils": "1.9.7",
"ci-info": "3.3.0",
"cross-env": "7.0.3",
"eslint": "8.11.0",
Expand Down Expand Up @@ -162,4 +163,4 @@
"engines": {
"node": ">=14"
}
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14587,4 +14587,4 @@ zepto@^1.2.0:
zwitch@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920"
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==