diff --git a/README.md b/README.md index 074ab3430..f350082f2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 微博 - 博主 - 关键词 +- 即刻 + - 主题 + - 用户动态 - 网易云音乐 - 歌单歌曲 - 用户歌单 diff --git a/docs/README.md b/docs/README.md index 143117261..985c984cf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -203,6 +203,24 @@ s 参数: keyword,你想订阅的微博关键词 +## 即刻 + +### 主题 + +举例: [https://rss.now.sh/jike/topic/54dffb40e4b0f57466e675f0](https://rss.now.sh/jike/topic/54dffb40e4b0f57466e675f0) + +路由: `/jike/topic/:id` + +参数: id,主题 id,可在即刻 web 端主题页或 APP 分享出来的主题页 URL 中找到 + +### 用户动态 + +举例: [https://rss.now.sh/jike/user/82D23B32-CF36-4C59-AD6F-D05E3552CBF3](https://rss.now.sh/jike/user/82D23B32-CF36-4C59-AD6F-D05E3552CBF3) + +路由: `/jike/user/:id` + +参数: id,用户 id,可在即刻 web 端用户页 URL 中找到 + ## 网易云音乐 ### 歌单歌曲 diff --git a/router.js b/router.js index 2d98ba033..b2f71ce21 100644 --- a/router.js +++ b/router.js @@ -108,4 +108,8 @@ router.get('/instagram/user/:id', require('./routes/instagram/user')); router.get('/youtube/user/:username', require('./routes/youtube/user')); router.get('/youtube/channel/:id', require('./routes/youtube/channel')); +// 即刻 +router.get('/jike/topic/:id', require('./routes/jike/topic')); +router.get('/jike/user/:id', require('./routes/jike/user')); + module.exports = router; diff --git a/routes/jike/topic.js b/routes/jike/topic.js new file mode 100644 index 000000000..a28030f39 --- /dev/null +++ b/routes/jike/topic.js @@ -0,0 +1,56 @@ +const axios = require('axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await axios({ + method: 'get', + url: `https://app.jike.ruguoapp.com/1.0/messages/showDetail?topicId=${id}`, + headers: { + 'User-Agent': config.ua, + 'Referer': `https://m.okjike.com/topics/${id}`, + 'App-Version': '3.5.0' + } + }); + + const data = response.data; + + ctx.state.data = { + title: data.topic.content, + link: `https://web.okjike.com/topic/${id}/official`, + description: data.topic.briefIntro, + image: data.topic.pictureUrl, + item: data.messages.map((item) => { + let contentTemplate = item.content; + if (item.linkUrl) { + contentTemplate = `${item.content}`; + } + if (item.personalUpdate && item.personalUpdate.linkUrl) { + contentTemplate = `${item.content}`; + } + + let imgTemplate = ''; + item.pictureUrls && item.pictureUrls.forEach((item) => { + imgTemplate += `
`; + }); + item.personalUpdate && item.personalUpdate.pictureUrls && item.personalUpdate.pictureUrls.forEach((item) => { + imgTemplate += `
`; + }); + + let videoTemplate = ''; + if (item.video) { + videoTemplate = `
视频: `; + } + if (item.personalUpdate && item.personalUpdate.video) { + videoTemplate = `
视频: `; + } + return { + title: item.content, + description: `${contentTemplate}${imgTemplate}${videoTemplate}`, + pubDate: new Date(item.createdAt).toUTCString(), + link: `https://web.okjike.com/message-detail/${item.id}/officialMessage` + } + }), + }; +}; \ No newline at end of file diff --git a/routes/jike/user.js b/routes/jike/user.js new file mode 100644 index 000000000..9865ffca2 --- /dev/null +++ b/routes/jike/user.js @@ -0,0 +1,54 @@ +const axios = require('axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await axios({ + method: 'post', + url: 'https://app.jike.ruguoapp.com/1.0/personalUpdate/single', + headers: { + 'User-Agent': config.ua, + 'Referer': `https://web.okjike.com/user/${id}`, + 'App-Version': '4.1.0', + 'platform': 'web' + }, + data: { + limit: 20, + loadMoreKey: null, + username: id + }, + }); + + const data = response.data.data; + + ctx.state.data = { + title: `${data[0].user.screenName}的即刻动态`, + link: `https://web.okjike.com/user/${id}`, + image: data[0].user.avatarImage.picUrl, + item: data.map((item) => { + const typeMap = { + 'ORIGINAL_POST': '发布', + 'REPOST': '转发' + }; + + let linkTemplate = ''; + if (item.linkInfo && item.linkInfo.linkUrl) { + linkTemplate = `
${item.linkInfo.title}`; + } + + let imgTemplate = ''; + item.pictures && item.pictures.forEach((item) => { + imgTemplate += `
`; + }); + + const content = item.content || item.linkInfo && item.linkInfo.title || item.target && item.target.content; + return { + title: `${typeMap[item.type]}了: ${content}`, + description: `${content}${linkTemplate}${imgTemplate}`, + pubDate: new Date(item.createdAt).toUTCString(), + link: `https://web.okjike.com/message-detail/${item.id}/officialMessage` + } + }), + }; +}; \ No newline at end of file