feat: New Route Miyoushe - User Follow Dynamics | 新增路由 米游社 - 用户关注动态 (#14425)
* feat(route): 增加 米游社 - 用户关注动态 路由 * fix(route): 修复 路由、文档的风格问题 * docs: fix envs ---------
This commit is contained in:
parent
9d8fc0e356
commit
b63690c64a
|
|
@ -234,6 +234,9 @@ const calculateValue = () => {
|
|||
cookies: medium_cookies,
|
||||
articleCookie: envs.MEDIUM_ARTICLE_COOKIE || '',
|
||||
},
|
||||
mihoyo: {
|
||||
cookie: envs.MIHOYO_COOKIE,
|
||||
},
|
||||
miniflux: {
|
||||
instance: envs.MINIFLUX_INSTANCE || 'https://reader.miniflux.app',
|
||||
token: envs.MINIFLUX_TOKEN || '',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = {
|
||||
getUserFullInfo: (ctx, uid) => {
|
||||
if (!uid && !config.mihoyo.cookie) {
|
||||
throw 'GetUserFullInfo is not available due to the absense of [Miyoushe Cookie]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
|
||||
}
|
||||
uid ||= '';
|
||||
const key = 'mihoyo:user-full-info-uid-' + uid;
|
||||
return ctx.cache.tryGet(key, async () => {
|
||||
const query = new URLSearchParams({
|
||||
|
|
@ -14,19 +19,21 @@ module.exports = {
|
|||
url,
|
||||
headers: {
|
||||
Referer: `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`,
|
||||
Cookie: config.mihoyo.cookie,
|
||||
},
|
||||
});
|
||||
const userInfo = response?.data?.data?.user_info;
|
||||
if (!userInfo) {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const { nickname, introduce, gender, certification, avatar_url } = userInfo;
|
||||
const { nickname, introduce, gender, certification, avatar_url, uid: userId } = userInfo;
|
||||
return {
|
||||
nickname,
|
||||
introduce,
|
||||
gender,
|
||||
certification,
|
||||
avatar_url,
|
||||
uid: userId,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const cache = require('./cache');
|
||||
const config = require('@/config').value;
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.mihoyo.cookie) {
|
||||
throw 'Miyoushe Timeline is not available due to the absense of [Miyoushe Cookie]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
|
||||
}
|
||||
|
||||
const page_size = ctx.query.limit || '20';
|
||||
const searchParams = {
|
||||
gids: 2,
|
||||
page_size,
|
||||
};
|
||||
const link = 'https://www.miyoushe.com/ys/timeline';
|
||||
const url = 'https://bbs-api.miyoushe.com/post/wapi/timelines';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams,
|
||||
headers: {
|
||||
Referer: link,
|
||||
Cookie: config.mihoyo.cookie,
|
||||
},
|
||||
});
|
||||
const list = response?.data?.data?.list;
|
||||
if (!list) {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const { nickname: username } = await cache.getUserFullInfo(ctx, '');
|
||||
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;
|
||||
};
|
||||
|
|
@ -2,6 +2,7 @@ module.exports = {
|
|||
'/bbs/follow-list/:uid': ['CaoMeiYouRen'],
|
||||
'/bbs/img-ranking/:game/:routeParams?': ['CaoMeiYouRen'],
|
||||
'/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'],
|
||||
'/bbs/timeline': ['CaoMeiYouRen'],
|
||||
'/bbs/user-post/:uid': ['CaoMeiYouRen'],
|
||||
'/sr/:location?/:category?': ['shinanory'],
|
||||
'/ys/:location?/:category?': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ const bbs = [
|
|||
return `/mihoyo/bbs/user-post/${uid}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '米游社 - 用户关注动态',
|
||||
docs: 'https://docs.rsshub.app/routes/game#mi-ha-you',
|
||||
source: '/:game/timeline',
|
||||
target: '/mihoyo/bbs/timeline',
|
||||
},
|
||||
];
|
||||
module.exports = {
|
||||
'hoyoverse.com': {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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/timeline', require('./bbs/timeline'));
|
||||
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'));
|
||||
|
|
|
|||
|
|
@ -570,6 +570,10 @@ Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即
|
|||
|
||||
- `HEFENG_KEY`:API key
|
||||
|
||||
### 米游社
|
||||
|
||||
- `MIHOYO_COOKIE`:登录米游社后的 cookie,用于获取用户关注动态时间线。
|
||||
|
||||
### 南方周末
|
||||
|
||||
用于付费全文
|
||||
|
|
|
|||
|
|
@ -735,6 +735,14 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
|||
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/user-post/77005350" path="/mihoyo/bbs/user-post/:uid" paramsDesc={['用户uid']} radar="1" />
|
||||
|
||||
### 米游社 - 用户关注动态 {#mi-ha-you-mi-you-she-yong-hu-guan-zhu-dong-tai}
|
||||
|
||||
<Route author="CaoMeiYouRen" example="/mihoyo/bbs/timeline" path="/mihoyo/bbs/timeline" radar="1" configRequired="1">
|
||||
:::warning
|
||||
用户关注动态需要米游社登录后的 Cookie 值,所以只能自建,详情见部署页面的配置模块。
|
||||
:::
|
||||
</Route>
|
||||
|
||||
### 原神 {#mi-ha-you-yuan-shen}
|
||||
|
||||
#### 新闻 {#mi-ha-you-yuan-shen-xin-wen}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
<Route author="nczitzk" example="/cia/foia-annual-report" path="/cia/foia-annual-report" notOperational="1" />
|
||||
|
||||
## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-w%C3%BCrttemberg-germany}
|
||||
## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-wvrttemberg-germany}
|
||||
|
||||
### Press releases {#constitutional-court-of-baden-w%C3%BCrttemberg-germany-press-releases}
|
||||
### Press releases {#constitutional-court-of-baden-wvrttemberg-germany-press-releases}
|
||||
|
||||
<Route author="quinn-dev" example="/verfghbw/press" path="/verfghbw/press/:keyword?" paramsDesc={['Keyword']} notOperational="1" />
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store)
|
|||
|
||||
<Route author="DIYgod" example="/scmp/coronavirus" path="/scmp/coronavirus" />
|
||||
|
||||
### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electr%C3%B3nica-especial-contra-epidemias-what-s-new}
|
||||
### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electronica-especial-contra-epidemias-what-s-new}
|
||||
|
||||
Official Website: [https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx](https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx)
|
||||
|
||||
|
|
|
|||
|
|
@ -553,6 +553,10 @@ Web 版认证 token 和 iOS 内购回执认证 token 只需选择其一填入即
|
|||
|
||||
- `TOPHUB_COOKIE`: 今日热榜登录后的 cookie,目前只需要 `itc_center_user=...` 以获取原始链接
|
||||
|
||||
### 米游社
|
||||
|
||||
- `MIHOYO_COOKIE`:登录米游社后的 cookie,用于获取用户关注动态时间线。
|
||||
|
||||
### 南方周末
|
||||
|
||||
付费全文
|
||||
|
|
|
|||
Loading…
Reference in New Issue