增加:煎蛋-热榜-妹子图 (#899)

* 增加:有品-每日上新

* 修复 summary 字段错误

* 将 youpin 模块转移至 mi 目录下,并更新文档

* 增加:煎蛋-热榜-妹子图

* 修改文档,妹子图与热榜-妹子图合并
This commit is contained in:
凉凉
2018-10-16 18:20:54 +08:00
committed by DIYgod
parent 4402756c0a
commit 6dee8af709
2 changed files with 34 additions and 16 deletions
+5 -1
View File
@@ -767,7 +767,11 @@ GitHub 官方也提供了一些 RSS:
<route name="无聊图" author="Xuanwo" example="/jandan/pic" path="/jandan/:sub_model" :paramsDesc="['煎蛋板块名称']"/>
<route name="妹子图" author="kobemtl" example="/jandan/ooxx" path="/jandan/:sub_model" :paramsDesc="['煎蛋板块名称']"/>
<route name="妹子图" author="kobemtl xyqfer" example="/jandan/ooxx" path="/jandan/:sub_model" :paramsDesc="['煎蛋板块名称']"/>
| 妹子图 | 热榜 |
| ------ | -------- |
| ooxx | top-ooxx |
### 喷嚏
+29 -15
View File
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const items = Array();
const items = [];
$('.commentlist > li').each((_, item) => {
// Get current comment id, if comment_id is 'adsense', just need to skip..
const comment_id = $(item).attr('id');
@@ -29,32 +29,43 @@ module.exports = async (ctx) => {
}
// Get current comment's link.
const link = $(item)
let link = $(item)
.find('.righttext')
.find('a')
.attr('href');
if (link === undefined) {
return;
if (link !== undefined) {
link = `http:${link}`;
} else {
// sub_model 为 top-ooxx 时无链接
link = '';
}
// Get current comment's images.
// TODO: should support multiple images.
let img_url = $(item)
.find('.text')
.find('.img-hash')
.html();
if (img_url === null) {
const imgList = [];
$(item)
.find('.text .img-hash')
.each((_, item) => {
const imgUrl = $(item).html();
if (imgUrl !== undefined) {
imgList.push(jandan_decode(imgUrl).replace(/(\/\/\w+\.sinaimg\.cn\/)(\w+)(\/.+\.(gif|jpg|jpeg))/, '$1large$3'));
}
});
if (imgList.length === 0) {
return;
}
img_url = jandan_decode(img_url);
img_url = img_url.replace(/(\/\/\w+\.sinaimg\.cn\/)(\w+)(\/.+\.(gif|jpg|jpeg))/, '$1large$3');
// TODO: should load user's comments.
items.push({
guid: comment_id,
title: comment_id,
description: `<img referrerpolicy="no-referrer" src="http:${img_url}">`,
link: `http:${link}`,
description: imgList.reduce((description, imgUrl) => {
description += `<img referrerpolicy="no-referrer" src="http:${imgUrl}"><br>`;
return description;
}, ''),
link,
});
});
@@ -66,6 +77,9 @@ module.exports = async (ctx) => {
} else if (sub_model === 'ooxx') {
rss_title = '煎蛋妹子图';
description = '这儿才是正版妹子图。';
} else if (sub_model === 'top-ooxx') {
rss_title = '煎蛋妹子图热榜';
description = ''; // TODO: 这里写啥好
}
ctx.state.data = {