-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -74,6 +74,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 | |
- 开发者头条 | ||
- 今天头条 | ||
- 独家号 | ||
- Disqus | ||
- 评论 | ||
|
||
## 参与我们 | ||
|
||
|
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
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,52 @@ | ||
const axios = require('axios'); | ||
const template = require('../../utils/template'); | ||
const config = require('../../config'); | ||
|
||
module.exports = async (ctx) => { | ||
const forum = ctx.params.forum; | ||
|
||
const response = await axios({ | ||
method: 'get', | ||
url: `https://disqus.com/api/3.0/forums/listPosts.json?api_key=${config.disqus.api_key}&forum=${forum}`, | ||
headers: { | ||
'User-Agent': config.ua, | ||
'Referer': 'https://disqus.com/' | ||
} | ||
}); | ||
|
||
const data = response.data.response; | ||
|
||
const threadsObj = {}; | ||
data.forEach((item) => { | ||
threadsObj[item.thread] = 1; | ||
}); | ||
let threadsQuery = ''; | ||
Object.keys(threadsObj).forEach((item) => { | ||
threadsQuery += `&thread=${item}`; | ||
}); | ||
|
||
const responseThreads = await axios({ | ||
method: 'get', | ||
url: `https://disqus.com/api/3.0/forums/listThreads.json?api_key=${config.disqus.api_key}&forum=${forum}${threadsQuery}`, | ||
headers: { | ||
'User-Agent': config.ua, | ||
'Referer': 'https://disqus.com/' | ||
} | ||
}); | ||
|
||
const threads = responseThreads.data.response; | ||
|
||
ctx.body = template({ | ||
title: `${forum} 的评论`, | ||
description: `${forum} 的 disqus 评论`, | ||
item: data.map((item) => { | ||
const thread = threads.filter((i) => i.id === item.thread)[0]; | ||
return { | ||
title: `${item.author.name}: ${item.raw_message > 24 ? item.raw_message.slice(0, 24) + '...' : item.raw_message}`, | ||
description: `${item.author.name} 在《${thread.clean_title}》中发表评论: ${item.message}`, | ||
pubDate: new Date(item.createdAt).toUTCString(), | ||
link: `${thread.link}/#comment-${item.id}` | ||
}; | ||
}), | ||
}); | ||
}; |
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