mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: 极客时间相关内容添加全文输出 (#2507)
* 添加极客时间|极客新闻 RSS * 极客新闻RSS - 调整md文档格式 * 极客时间相关内容添加全文输出 * 极客时间全文输出 - 将缓存时间MaxAge参数值置空
This commit is contained in:
@@ -33,15 +33,55 @@ module.exports = async (ctx) => {
|
||||
|
||||
const articles = latest_response.data.data.list;
|
||||
|
||||
const out = await Promise.all(
|
||||
articles.map(async (item) => {
|
||||
const title = item.article_title;
|
||||
const pubDate = new Date(item.article_ctime * 1000).toUTCString();
|
||||
const link = `https://time.geekbang.org/column/article/${item.id}`;
|
||||
const description = item.article_summary;
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
pubDate: pubDate,
|
||||
link: link,
|
||||
description: description,
|
||||
};
|
||||
|
||||
if (item.id !== undefined) {
|
||||
const value = ctx.cache.get(item.id);
|
||||
if (value) {
|
||||
single.description = value;
|
||||
} else {
|
||||
try {
|
||||
const article_response = await got({
|
||||
method: 'post',
|
||||
url: 'https://time.geekbang.org/serv/v1/article',
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
json: true,
|
||||
data: {
|
||||
id: item.id,
|
||||
include_neighbors: true,
|
||||
},
|
||||
});
|
||||
|
||||
single.description = article_response.data.data.article_content;
|
||||
ctx.cache.set(item.id, single.description);
|
||||
} catch (err) {
|
||||
single.description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
out.reverse();
|
||||
ctx.state.data = {
|
||||
title: intro_data.column_title,
|
||||
link: `https://time.geekbang.org/column/intro/${column_id}`,
|
||||
description: intro_data.column_subtitle,
|
||||
item: articles.map((item) => ({
|
||||
title: item.article_title,
|
||||
description: item.article_summary,
|
||||
pubDate: new Date(item.article_ctime * 1000).toUTCString(),
|
||||
link: `https://time.geekbang.org/column/article/${item.id}`,
|
||||
})),
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user