Add jike/topicText (#637)

Fix #635, partially fix / #621
This commit is contained in:
Henry Wang 2018-09-03 16:17:53 +01:00 committed by DIYgod
parent 31dce889e9
commit 4f603d0224
5 changed files with 60 additions and 0 deletions

View File

@ -1498,6 +1498,12 @@ GitHub 官方也提供了一些 RSS:
### 主题-精选 <Author uid="DIYgod"/>
::: tip 提示
部分主题如 `一觉醒来发生了什么: 553870e8e4b0cafb0a1bef68` 提供纯文字内容, <a href="#主题-纯文字">主题-纯文字 jike/topicText</a> 可能会提供更好的体验.
:::
举例: <https://rsshub.app/jike/topic/54dffb40e4b0f57466e675f0>
路由: `/jike/topic/:id`
@ -1516,6 +1522,16 @@ GitHub 官方也提供了一些 RSS:
- id, 主题 id, 可在即刻 web 端主题页或 APP 分享出来的主题页 URL 中找到
### 主题-纯文字 <Author uid="HenryQW"/>
举例: <https://rsshub.app/jike/topic/text/553870e8e4b0cafb0a1bef68>
路由: `/jike/topic/text/:id`
参数:
- id, 主题 id, 可在即刻 web 端主题页或 APP 分享出来的主题页 URL 中找到
### 用户动态 <Author uid="DIYgod"/>
举例: <https://rsshub.app/jike/user/82D23B32-CF36-4C59-AD6F-D05E3552CBF3>

View File

@ -46,6 +46,7 @@
"co-redis": "2.1.1",
"crypto": "1.0.1",
"currency-symbol-map": "^4.0.4",
"dayjs": "^1.7.5",
"form-data": "^2.3.2",
"git-rev-sync": "1.12.0",
"googleapis": "33.0.0",

View File

@ -231,6 +231,7 @@ if (config.youtube && config.youtube.key) {
// 即刻
router.get('/jike/topic/:id', require('./routes/jike/topic'));
router.get('/jike/topic/text/:id', require('./routes/jike/topicText'));
router.get('/jike/topic/square/:id', require('./routes/jike/topicSquare'));
router.get('/jike/user/:id', require('./routes/jike/user'));
router.get('/jike/daily', require('./routes/jike/daily'));

38
routes/jike/topicText.js Normal file
View File

@ -0,0 +1,38 @@
const axios = require('../../utils/axios');
const dayjs = require('dayjs');
module.exports = async (ctx) => {
const id = ctx.params.id;
const response = await axios({
method: 'post',
url: 'https://app.jike.ruguoapp.com/1.0/messages/history',
headers: {
Referer: `https://m.okjike.com/topics/${id}`,
'App-Version': '4.1.0',
},
data: {
loadMoreKey: null,
topic: id,
limit: 5,
},
});
const data = response.data.data;
const title = data[0].topic.content;
ctx.state.data = {
title: `${title} - 即刻`,
link: `https://web.okjike.com/topic/${id}/official`,
description: `${title} - 即刻`,
item: data.map((item) => {
const date = new Date(item.createdAt);
return {
title: `${title} ${dayjs(date).format('YYYY-MM-DD')}`,
description: item.content.replace(new RegExp('\n', 'g'), '<br />'),
pubDate: date.toUTCString(),
link: `https://web.okjike.com/message-detail/${item.id}/officialMessage`,
};
}),
};
};

View File

@ -2224,6 +2224,10 @@ date-now@^0.1.4:
version "0.1.4"
resolved "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
dayjs@^1.7.5:
version "1.7.5"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.7.5.tgz#14715cb565d1f8cb556a8531cb14bf1fc33067cc"
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"