mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
const got = require('@/utils/got');
|
|
|
|
module.exports = async (ctx) => {
|
|
const id = ctx.params.id;
|
|
|
|
const apiUrl = `https://app.yinxiang.com/third/discovery/client/restful/public/blog-user/homepage?encryptedUserId=${id}&lastNoteGuid=¬ePageSize=20`;
|
|
const response = await got({
|
|
method: 'get',
|
|
url: apiUrl,
|
|
});
|
|
|
|
const list = response.data.blogNote.map((item) => ({
|
|
title: item.title,
|
|
link: item.noteGuid,
|
|
author: item.userNickname,
|
|
}));
|
|
|
|
const items = await Promise.all(
|
|
list.map(
|
|
async (item) =>
|
|
await ctx.cache.tryGet(item.link, async () => {
|
|
const detailResponse = await got({
|
|
method: 'get',
|
|
url: `https://app.yinxiang.com/third/discovery/client/restful/public/blog-note?noteGuid=${item.link}`,
|
|
});
|
|
|
|
item.link = `https://www.yinxiang.com/everhub/note/${item.link}`;
|
|
item.pubDate = new Date(parseInt(detailResponse.data.blogNote.publishTime)).toUTCString();
|
|
|
|
const description = detailResponse.data.blogNote.htmlContent;
|
|
if (description.indexOf('<?xml') < 0) {
|
|
item.description = description;
|
|
} else {
|
|
item.description = description.match(/<en-note>(.*)<\/en-note>/)[1];
|
|
}
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: `${response.data.blogUser.nickname} - 印象识堂`,
|
|
link: `https://www.yinxiang.com/everhub/category/${id}`,
|
|
description: response.data.blogUser.introduction,
|
|
item: items,
|
|
};
|
|
};
|