add qqtucao
This commit is contained in:
parent
998c286b31
commit
c813337d87
|
|
@ -449,6 +449,16 @@ city: 城市的中文名,可选,默认北京
|
|||
|
||||
参数: 无
|
||||
|
||||
### 腾讯吐个槽
|
||||
|
||||
#### 吐槽新帖
|
||||
|
||||
举例: https://rss.now.sh/tucaoqq/post/28564/CdRI0728
|
||||
|
||||
路由: `/tucaoqq/post`
|
||||
|
||||
参数: project 产品ID key 产品密钥
|
||||
|
||||
## 搭建
|
||||
|
||||
环境:需要 Node.js v7.6.0 或更高版本,若启用 Redis 缓存需要先启动 Redis
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
"crypto": "1.0.1",
|
||||
"eslint": "4.19.1",
|
||||
"form-data": "^2.3.2",
|
||||
"js-md5": "^0.7.3",
|
||||
"json-bigint": "0.2.3",
|
||||
"koa": "2.5.0",
|
||||
"koa-redis-cache": "3.0.0",
|
||||
|
|
|
|||
|
|
@ -74,4 +74,6 @@ router.get('/jandan/pic', require('./routes/jandan/pic'));
|
|||
// 喷嚏
|
||||
router.get('/dapenti/tugua', require('./routes/dapenti/tugua'));
|
||||
|
||||
// 腾讯吐个槽
|
||||
router.get('/tucaoqq/post/:project/:key', require('./routes/tucaoqq/post'));
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
const axios = require('axios');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
const md5 = require('js-md5');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const projectID = ctx.params.project;
|
||||
const key = ctx.params.key;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://support.qq.com/api/v1/${projectID}/posts`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
'Timestamp': Math.round(+new Date() / 1000).toString(),
|
||||
'Signature': md5(Math.round(+new Date() / 1000).toString() + key)
|
||||
}
|
||||
});
|
||||
const data = response.data.data;
|
||||
|
||||
ctx.body = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: `${projectID} 的 吐个槽新帖`,
|
||||
link: `https://support.qq.com/product/${projectID}`,
|
||||
description: `${projectID} 的 吐个槽新帖`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: data.map((item) => {
|
||||
let pubdate = new Date(item.created_at.replace(' ', 'T') + "+08:00");
|
||||
let imgHTML = '';
|
||||
if (data.images) {
|
||||
for (let i = 0; i < data.images.length; i++) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${data.images[i]}">`;
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: item.nick_name + ' 的吐槽',
|
||||
description: `${item.content}${imgHTML}`,
|
||||
pubDate: pubdate.toUTCString(),
|
||||
link: `https://support.qq.com/products/${projectID}`
|
||||
};
|
||||
}),
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue