Skip to content

Commit

Permalink
Add jike/topicText (DIYgod#637)
Browse files Browse the repository at this point in the history
Fix DIYgod#635, partially fix / DIYgod#621
  • Loading branch information
HenryQW authored and DIYgod committed Sep 3, 2018
1 parent 31dce88 commit 4f603d0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
38 changes: 38 additions & 0 deletions routes/jike/topicText.js
Original file line number Diff line number Diff line change
@@ -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`,
};
}),
};
};
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4f603d0

Please sign in to comment.