feat: add nosetime (#2623)

This commit is contained in:
Cloud
2019-07-16 11:05:53 +08:00
committed by DIYgod
parent 6e70fea144
commit cee08ee087
4 changed files with 94 additions and 0 deletions
+10
View File
@@ -887,6 +887,16 @@ type 为 all 时,category 参数不支持 cost 和 free
</Route>
## 香水时代
### 首页
<Route author="kt286" example="/nosetime/home" path="/nosetime/home"/>
### 香评
<Route author="kt286" example="/nosetime/59247733/discuss/new" path="/nosetime/:id/:type/:sort?" :paramsDesc="['用户id,可在用户主页 URL 中找到', '类型,short 一句话香评 discuss 香评', '排序, new 最新 agree 最有用']"/>
## 新浪专栏
### 创事记
+4
View File
@@ -1495,4 +1495,8 @@ router.get('/aptonic/action', require('./routes/aptonic/action'));
// 印记中文周刊
router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
// 香水时代
router.get('/nosetime/:id/:type/:sort?', require('./routes/nosetime/comment'));
router.get('/nosetime/home', require('./routes/nosetime/home'));
module.exports = router;
+52
View File
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const id = ctx.params.id;
const type = ctx.params.type || 'discuss'; // short一句话 discuss
const sort = ctx.params.sort || 'new'; // new最新 agree最有用
const link = `https://www.nosetime.com/member/member_comment.php?id=${id}&type=${type}&o=${sort}`;
const userinfo = await got({
method: 'POST',
url: 'https://www.nosetime.com/app/user.php',
headers: {
Referer: link,
'Content-Type': 'application/json;charset=utf-8',
},
data: JSON.stringify({
method: 'getsocialinfo',
id: id,
}),
});
const response = await got({
method: 'POST',
url: 'https://www.nosetime.com/app/user.php',
headers: {
Referer: link,
'Content-Type': 'application/json;charset=utf-8',
},
data: JSON.stringify({
method: `getweb${type}`,
id: id,
orderby: sort,
page: 1,
}),
});
const items = response.data.items.map((item) => ({
title: `${'★★★★★☆☆☆☆☆'.slice(5 - item.score, 10 - item.score)} ${item.name}`,
description: item.content,
pubDate: new Date(item.time).toUTCString(),
link: `https://www.nosetime.com/xiangshui/${item.id}-${item.iurl}.html`,
author: userinfo.data.uname,
}));
ctx.state.data = {
title: `香水时代 - ${userinfo.data.uname}`,
link: link,
description: userinfo.data.udesc,
item: items,
};
};
+28
View File
@@ -0,0 +1,28 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const link = `https://www.nosetime.com/perfume.php`;
const response = await got({
method: 'GET',
url: 'https://www.nosetime.com/app/smart.php?page=1&type=discovery',
headers: {
Referer: link,
},
});
const items = response.data.items.map((item) => ({
title: `${'★★★★★☆☆☆☆☆'.slice(5 - item.uwscore, 10 - item.uwscore)} ${item.ifullname}`,
description: item.udcontent,
pubDate: new Date(item.uface * 1000).toUTCString(),
link: `https://www.nosetime.com/xiangshui/${item.iid}-${item.iurl}.html`,
author: item.uname,
}));
ctx.state.data = {
title: `香水时代`,
link: link,
description: '最新香水评论|发现香水圈的新鲜事 - 香水时代NoseTime.com',
item: items,
};
};