-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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): New route: MiYouShe - User Posts; Optimize the routing of MiYouShe | 新增路由:米游社 - 用户帖子;优化米游社路由 #14268
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
83a7846
fix(route): 修复 米游社 公告栏 template 错误
CaoMeiYouRen 7b65948
Merge branch 'DIYgod:master' into master
CaoMeiYouRen 2ea08ff
feat(route): 新增 bing 搜索
CaoMeiYouRen de072b3
docs: Update other.mdx
CaoMeiYouRen 98aee17
docs: fix docs
TonyRL 13b91e1
feat(route): 新增 百度搜索
CaoMeiYouRen 32d028a
Merge branch 'master' of github.com:CaoMeiYouRen/RSSHub
CaoMeiYouRen dd283a2
fix(route): 修复 pubDate 解析错误
CaoMeiYouRen 288b606
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen b0b6b4d
fix(route): 优化 百度搜索的缓存,减轻反爬问题
CaoMeiYouRen e9afda3
feat(route): 新增 360 搜索
CaoMeiYouRen 3171faa
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 7abe59c
feat(route): 迁移 搜狗特色LOGO 到 v2 规范;添加 搜狗搜索
CaoMeiYouRen 4751557
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 7f68ac2
fix(route): 百度搜索增加图片
CaoMeiYouRen 12d0477
feat(route): 新增 Google Search
CaoMeiYouRen f81821d
chore: merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 05ce45c
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 1185a64
fix(route): 修复 百度搜索相关问题
CaoMeiYouRen 58c722d
fix(route): 修复 Google 相关问题
CaoMeiYouRen 1b00eb6
fix(route): 修复 360 搜索
CaoMeiYouRen 08dca4d
fix(route): 修复 搜狗搜索
CaoMeiYouRen 90b1aa7
fix(route): 修复 await 问题
CaoMeiYouRen da49d03
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 931b769
fix: 移除 google sites
CaoMeiYouRen a997c01
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen 22923a5
fix(route): 修复 缓存和过滤逻辑问题
CaoMeiYouRen 90ebcd6
Merge branch 'master' of github.com:DIYgod/RSSHub
CaoMeiYouRen cd5d832
fix(route): 修复 360 搜索缺少 cookie 的问题
CaoMeiYouRen 31118c2
fix(route): 修复 360 搜索 cookie 的问题
CaoMeiYouRen 219f9d8
feat(route): 移除 so.com 路由
CaoMeiYouRen c548af5
fix: merge conflict
TonyRL fd464c1
Merge branch 'DIYgod:master' into master
CaoMeiYouRen cddabf8
feat(route): 新增路由:米游社 - 用户帖子;优化米游社路由
CaoMeiYouRen 49aa866
fix(route): 修复 米游社用户帖子路由
CaoMeiYouRen 3123b9a
feat(route): 新增 米游社 用户关注路由
CaoMeiYouRen 895cf2e
fix(route): 修复 米游社帖子可能缺失封面的 bug;增加 点赞和评论数
CaoMeiYouRen 4b5773e
fix(route): 修复 米游社路由的规范和 bug
CaoMeiYouRen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass the query string into got's
searchParams
optiondocs: https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#url
https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#searchparams