fix: url in aiyanxishe (#2473)

This commit is contained in:
Chenyang Shi
2019-06-24 22:38:10 +08:00
committed by DIYgod
parent ff7a771fa6
commit e35f41f55f
+9 -4
View File
@@ -27,17 +27,20 @@ module.exports = async (ctx) => {
},
});
const ProcessFeed = (type, data) => {
const ProcessFeed = (type, data, id) => {
let description = '';
let author = '';
let link;
switch (type) {
case 'blog': // 博客
description = data.content;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/blogDetail/${id}`;
break;
case 'question': // 问答
description = data.content;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/questionDetail/${id}`;
break;
case 'article': // 翻译
description = `<table><tr><td width="50%"> ${data.title} </td><td> ${data.zh_title} </td></tr>`;
@@ -57,6 +60,7 @@ module.exports = async (ctx) => {
}
</style>`;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/TextTranslation/${id}`;
break;
case 'paper': // 论文
description = `<h3>标题</h3><p> ${data.paper.title} </p>`;
@@ -66,6 +70,7 @@ module.exports = async (ctx) => {
description += `<h3>摘要</h3><p> ${data.paper.description} </p>`;
description += `<h3>推荐理由</h3><p><b> ${data.paper.userInfo.nickname} </b>: ${data.paper.recommend_reason} </p>`;
author = data.paper.userInfo.nickname;
link = `https://ai.yanxishe.com/page/paperDetail/${id}`;
break;
default:
description = '暂不支持此类型,请到 https://github.com/DIYgod/RSSHub/issues 反馈';
@@ -73,7 +78,7 @@ module.exports = async (ctx) => {
}
// 提取内容
return { author, description };
return { author, description, link };
};
const items = await Promise.all(
@@ -95,13 +100,13 @@ module.exports = async (ctx) => {
url: itemUrl,
});
const result = ProcessFeed(item.type, response.data.data);
const result = ProcessFeed(item.type, response.data.data, item.id);
const single = {
title: item.zh_title,
description: result.description,
pubDate: new Date(parseFloat(item.published_time + '000')).toUTCString(),
link: itemUrl,
link: result.link,
author: result.author,
};
ctx.cache.set(itemUrl, JSON.stringify(single));