fix: aiyanxishe (#5858)

This commit is contained in:
simoin
2020-10-13 11:30:18 +01:00
committed by GitHub
parent 6041624252
commit ba1824ba51
+17 -10
View File
@@ -4,7 +4,7 @@ module.exports = async (ctx) => {
const id = ctx.params.id;
const sort = ctx.params.sort || 'new';
let url = 'https://www.leiphone.com/club/api?page=1&size=30&parent_tag=';
let url = 'https://api.yanxishe.com/api?page=1&size=30&parent_tag=';
if (id === 'all') {
url += '&tag=';
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
method: 'GET',
url: url,
headers: {
Referer: `https://www.leiphone.com/club/api?page=1&size=30&is_hot=0&is_recommend=0&tag=&parent_tag='`,
Referer: `https://www.yanxishe.com/`,
},
});
@@ -35,12 +35,16 @@ module.exports = async (ctx) => {
case 'blog': // 博客
description = data.content;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/blogDetail/${id}`;
if (data.relation_special) {
link = `https://www.yanxishe.com/columnDetail/${id}`;
} else {
link = `https://www.yanxishe.com/blogDetail/${id}`;
}
break;
case 'question': // 问答
description = data.content;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/questionDetail/${id}`;
link = `https://www.yanxishe.com/questionDetail/${id}`;
break;
case 'article': // 翻译
description = `<table><tr><td width="50%"> ${data.title} </td><td> ${data.zh_title} </td></tr>`;
@@ -60,7 +64,7 @@ module.exports = async (ctx) => {
}
</style>`;
author = data.user.nickname;
link = `https://ai.yanxishe.com/page/TextTranslation/${id}`;
link = `https://www.yanxishe.com/TextTranslation/${id}`;
break;
case 'paper': // 论文
description = `<h3>标题</h3><p> ${data.paper.title} </p>`;
@@ -70,7 +74,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}`;
link = `https://paper.yanxishe.com/review/${id}`;
break;
default:
description = '暂不支持此类型,请到 https://github.com/DIYgod/RSSHub/issues 反馈';
@@ -83,11 +87,14 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.data.all.map(async (item) => {
let itemUrl = item.url;
let itemUrl = `https://api.yanxishe.com/api/sthread/${item.id}?token=null`;
// 修复论文链接
if (item.type === 'paper') {
itemUrl = 'https://www.leiphone.com/club/api/spaper/detail?id=' + item.id;
if (item.type === 'blog') {
itemUrl += '&type=null';
} else if (item.type === 'article') {
itemUrl = `https://api.yanxishe.com/api/stranslate/article/${item.id}?token=null&type=null`;
} else if (item.type === 'paper') {
itemUrl = `https://api.yanxishe.com/api/spaper/detail?token=null&id=${item.id}`;
}
const cache = await ctx.cache.get(itemUrl);