forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.js
36 lines (31 loc) · 1.4 KB
/
user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const getToken = require('./token');
const getIllusts = require('./api/getIllusts');
module.exports = async (ctx) => {
const id = ctx.params.id;
if (!getToken()) {
throw 'pixiv not login';
}
const response = await getIllusts(id, getToken());
const illusts = response.data.illusts;
const username = illusts[0].user.name;
ctx.state.data = {
title: `${username} 的 pixiv 动态`,
link: `https://www.pixiv.net/member.php?id=${id}`,
description: `${username} 的 pixiv 最新动态`,
item: illusts.map((illust) => {
const images = [];
if (illust.page_count === 1) {
images.push(`<p><img referrerpolicy="no-referrer" src="https://pixiv.cat/${illust.id}.jpg"/></p>`);
} else {
for (let i = 0; i < illust.page_count; i++) {
images.push(`<p><img referrerpolicy="no-referrer" src="https://pixiv.cat/${illust.id}-${i + 1}.jpg"/></p>`);
}
}
return {
title: illust.title,
description: `<p>画师:${username} - 上传于:${new Date(illust.create_date).toLocaleString('zh-cn')} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}</p>${images.join('')}`,
link: `https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${illust.id}`,
};
}),
};
};