feat(route): New route: MiYouShe - User Posts; Optimize the routing of MiYouShe | 新增路由:米游社 - 用户帖子;优化米游社路由 (#14268)
* fix(route): 修复 米游社 公告栏 template 错误 * feat(route): 新增 bing 搜索 * docs: Update other.mdx * docs: fix docs * feat(route): 新增 百度搜索 * fix(route): 修复 pubDate 解析错误 * fix(route): 优化 百度搜索的缓存,减轻反爬问题 * feat(route): 新增 360 搜索 * feat(route): 迁移 搜狗特色LOGO 到 v2 规范;添加 搜狗搜索 * fix(route): 百度搜索增加图片 * feat(route): 新增 Google Search * fix(route): 修复 百度搜索相关问题 * fix(route): 修复 Google 相关问题 * fix(route): 修复 360 搜索 * fix(route): 修复 搜狗搜索 * fix(route): 修复 await 问题 * fix: 移除 google sites * fix(route): 修复 缓存和过滤逻辑问题 * fix(route): 修复 360 搜索缺少 cookie 的问题 * fix(route): 修复 360 搜索 cookie 的问题 * feat(route): 移除 so.com 路由 * fix: merge conflict * feat(route): 新增路由:米游社 - 用户帖子;优化米游社路由 * fix(route): 修复 米游社用户帖子路由 * feat(route): 新增 米游社 用户关注路由 * fix(route): 修复 米游社帖子可能缺失封面的 bug;增加 点赞和评论数 * fix(route): 修复 米游社路由的规范和 bug ---------
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = {
|
||||
getUserFullInfo: (ctx, uid) => {
|
||||
const key = 'mihoyo:user-full-info-uid-' + uid;
|
||||
return ctx.cache.tryGet(key, async () => {
|
||||
const query = new URLSearchParams({
|
||||
uid,
|
||||
gids: 2,
|
||||
}).toString();
|
||||
const url = `https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo?${query}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`,
|
||||
},
|
||||
});
|
||||
const userInfo = response?.data?.data?.user_info;
|
||||
if (!userInfo) {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const { nickname, introduce, gender, certification, avatar_url } = userInfo;
|
||||
return {
|
||||
nickname,
|
||||
introduce,
|
||||
gender,
|
||||
certification,
|
||||
avatar_url,
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const cache = require('./cache');
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { uid } = ctx.params;
|
||||
const page_size = ctx.query.limit || '20';
|
||||
const searchParams = {
|
||||
gids: 2,
|
||||
uid,
|
||||
page_size,
|
||||
};
|
||||
const link = `https://www.miyoushe.com/ys/accountCenter/followList?id=${uid}`;
|
||||
const url = `https://bbs-api.miyoushe.com/user/wapi/following`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams,
|
||||
headers: {
|
||||
Origin: 'https://www.miyoushe.com',
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
const list = response?.data?.data?.result;
|
||||
if (!list) {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const { nickname: username } = await cache.getUserFullInfo(ctx, uid);
|
||||
const title = `米游社 - ${username} 的关注`;
|
||||
const items = list.map((e) => {
|
||||
const title = e.user.nickname;
|
||||
const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${e.user.uid}`;
|
||||
const description = renderDescription(`${e.user.certification.label || ''}\n${e.user.introduce || ''}`.trim(), [e.user.avatar_url]);
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
};
|
||||
});
|
||||
|
||||
const data = {
|
||||
title,
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
ctx.state.data = data;
|
||||
};
|
||||
@@ -78,7 +78,7 @@ module.exports = async (ctx) => {
|
||||
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 link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
@@ -87,14 +87,18 @@ module.exports = async (ctx) => {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [e.post.cover, ...e.post.images]);
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
});
|
||||
const data = {
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
|
||||
page_size,
|
||||
last_id,
|
||||
}).toString();
|
||||
const url = `https://bbs-api.mihoyo.com/post/wapi/getNewsList?${query}`;
|
||||
const url = `https://bbs-api.miyoushe.com/post/wapi/getNewsList?${query}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
||||
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 link = `https://www.miyoushe.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 {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { uid } = ctx.params;
|
||||
const size = ctx.query.limit || '20';
|
||||
const searchParams = {
|
||||
uid,
|
||||
size,
|
||||
};
|
||||
const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`;
|
||||
const url = `https://bbs-api.miyoushe.com/post/wapi/userPost`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams,
|
||||
});
|
||||
const list = response?.data?.data?.list;
|
||||
if (!list) {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const username = list[0]?.user.nickname;
|
||||
const title = `米游社 - ${username} 的发帖`;
|
||||
const items = list.map((e) => {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
});
|
||||
|
||||
const data = {
|
||||
title,
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
ctx.state.data = data;
|
||||
};
|
||||
@@ -1,6 +1,8 @@
|
||||
module.exports = {
|
||||
'/bbs/follow-list/:uid': ['CaoMeiYouRen'],
|
||||
'/bbs/img-ranking/:game/:routeParams?': ['CaoMeiYouRen'],
|
||||
'/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'],
|
||||
'/bbs/user-post/:uid': ['CaoMeiYouRen'],
|
||||
'/sr/:location?/:category?': ['shinanory'],
|
||||
'/ys/:location?/:category?': ['nczitzk'],
|
||||
};
|
||||
|
||||
+55
-32
@@ -1,3 +1,53 @@
|
||||
const bbs = [
|
||||
{
|
||||
title: '米游社 - 用户关注',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: '/:game/accountCenter/postList',
|
||||
target: (params, url) => {
|
||||
const uid = new URL(url).searchParams.get('id');
|
||||
return `/mihoyo/bbs/follow-list/${uid}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '米游社 - 同人榜',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: '/:game/imgRanking/:forum_id/:ranking_id/:cate_id',
|
||||
target: `/mihoyo/bbs/img-ranking/:game`,
|
||||
},
|
||||
{
|
||||
title: '米游社 - 官方公告',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53', '/:game/home/58'],
|
||||
target: (params, url) => {
|
||||
const GITS_MAP = {
|
||||
bh3: 1, // '崩坏三',
|
||||
ys: 2, // '原神',
|
||||
bh2: 3, // '崩坏二',
|
||||
wd: 4, // '未定事件簿',
|
||||
sr: 6, // '崩坏:星穹铁道',
|
||||
zzz: 8, // '绝区零'
|
||||
};
|
||||
const { game } = params;
|
||||
const gids = GITS_MAP[game];
|
||||
if (!gids) {
|
||||
return '';
|
||||
}
|
||||
const type = new URL(url).searchParams.get('type') || '1';
|
||||
const page_size = '20';
|
||||
const last_id = '';
|
||||
return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '米游社 - 用户帖子',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: '/:game/accountCenter/postList',
|
||||
target: (params, url) => {
|
||||
const uid = new URL(url).searchParams.get('id');
|
||||
return `/mihoyo/bbs/user-post/${uid}`;
|
||||
},
|
||||
},
|
||||
];
|
||||
module.exports = {
|
||||
'hoyoverse.com': {
|
||||
_name: '米哈游',
|
||||
@@ -20,38 +70,7 @@ module.exports = {
|
||||
},
|
||||
'mihoyo.com': {
|
||||
_name: '米哈游',
|
||||
bbs: [
|
||||
{
|
||||
title: '米游社 - 同人榜',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: '/:game/imgRanking/:forum_id/:ranking_id/:cate_id',
|
||||
target: `/mihoyo/bbs/img-ranking/:game`,
|
||||
},
|
||||
{
|
||||
title: '米游社 - 官方公告',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53', '/:game/home/58'],
|
||||
target: (params, url) => {
|
||||
const GITS_MAP = {
|
||||
bh3: 1, // '崩坏三',
|
||||
ys: 2, // '原神',
|
||||
bh2: 3, // '崩坏二',
|
||||
wd: 4, // '未定事件簿',
|
||||
sr: 6, // '崩坏:星穹铁道',
|
||||
zzz: 8, // '绝区零'
|
||||
};
|
||||
const { game } = params;
|
||||
const gids = GITS_MAP[game];
|
||||
if (!gids) {
|
||||
return '';
|
||||
}
|
||||
const type = new URL(url).searchParams.get('type') || '1';
|
||||
const page_size = '20';
|
||||
const last_id = '';
|
||||
return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`;
|
||||
},
|
||||
},
|
||||
],
|
||||
bbs,
|
||||
sr: [
|
||||
{
|
||||
title: '崩坏:星穹铁道 - 新闻',
|
||||
@@ -69,4 +88,8 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'miyoushe.com': {
|
||||
_name: '米游社',
|
||||
'.': bbs,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/bbs/follow-list/:uid', require('./bbs/follow-list'));
|
||||
router.get('/bbs/img-ranking/:game/:routeParams?', require('./bbs/img-ranking'));
|
||||
router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs/official'));
|
||||
router.get('/bbs/user-post/:uid', require('./bbs/user-post'));
|
||||
router.get('/sr/:location?/:category?', require('./sr/news'));
|
||||
router.get('/ys/:location?/:category?', require('./ys/news'));
|
||||
};
|
||||
|
||||
@@ -658,7 +658,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
|
||||
### 米游社 - 同人榜 {#mi-ha-you-mi-you-she-tong-ren-bang}
|
||||
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/img-ranking/ys/forumType=tongren&cateType=illustration&rankingType=daily" path="/bbs/img-ranking/:game/:routeParams?" paramsDesc={['游戏缩写','额外参数;请参阅以下说明和表格']} radar="1">
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/img-ranking/ys/forumType=tongren&cateType=illustration&rankingType=daily" path="/mihoyo/bbs/img-ranking/:game/:routeParams?" paramsDesc={['游戏缩写','额外参数;请参阅以下说明和表格']} radar="1">
|
||||
| 键 | 含义 | 接受的值 | 默认值 |
|
||||
| ----------- | ------------------------------------- | -------------------------------------------------------------------- | ------------ |
|
||||
| forumType | 主榜类型(仅原神、大别野有 cos 主榜) | tongren/cos | tongren |
|
||||
@@ -701,7 +701,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
|
||||
### 米游社 - 官方公告 {#mi-ha-you-mi-you-she-guan-fang-gong-gao}
|
||||
|
||||
<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">
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/official/2/3/20/" path="/mihoyo/bbs/official/:gids/:type?/:page_size?/:last_id?" paramsDesc={['游戏id','公告类型,默认为 2(即 活动)','分页大小,默认为 20 ','跳过的公告数,例如指定为 40 就是从第 40 条公告开始,可用于分页']} radar="1">
|
||||
游戏 id
|
||||
|
||||
| 崩坏三 | 原神 | 崩坏二 | 未定事件簿 | 星穹铁道 | 绝区零 |
|
||||
@@ -715,6 +715,14 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
| 1 | 2 | 3 |
|
||||
</Route>
|
||||
|
||||
### 米游社 - 用户关注 {#mi-ha-you-mi-you-she-yong-hu-guan-zhu}
|
||||
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/follow-list/77005350" path="/mihoyo/bbs/follow-list/:uid" paramsDesc={['用户uid']} radar="1" />
|
||||
|
||||
### 米游社 - 用户帖子 {#mi-ha-you-mi-you-she-yong-hu-tie-zi}
|
||||
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/user-post/77005350" path="/mihoyo/bbs/user-post/:uid" paramsDesc={['用户uid']} radar="1" />
|
||||
|
||||
### 原神 {#mi-ha-you-yuan-shen}
|
||||
|
||||
#### 新闻 {#mi-ha-you-yuan-shen-xin-wen}
|
||||
|
||||
Reference in New Issue
Block a user