fix(route): pixiv novels (#11629)
This commit is contained in:
parent
c532e4032b
commit
9a56bb8803
|
|
@ -4,32 +4,41 @@ const baseUrl = 'https://www.pixiv.net';
|
|||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const { data } = await got(`${baseUrl}/ajax/user/${id}/profile/all`);
|
||||
const url = `${baseUrl}/users/${id}/novels`;
|
||||
const { data: allData } = await got(`${baseUrl}/ajax/user/${id}/profile/all`, {
|
||||
headers: {
|
||||
referer: url,
|
||||
},
|
||||
});
|
||||
|
||||
const items = [
|
||||
...data.body.novelSeries.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.caption,
|
||||
link: `https://www.pixiv.net/novel/series/${item.id}`,
|
||||
author: item.userName,
|
||||
pubDate: parseDate(item.createDate),
|
||||
updated: parseDate(item.updateDate),
|
||||
category: item.tags,
|
||||
})),
|
||||
...data.body.pickup.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
link: item.contentUrl,
|
||||
author: item.userName,
|
||||
pubDate: parseDate(item.createDate),
|
||||
updated: parseDate(item.updateDate),
|
||||
category: item.tags,
|
||||
})),
|
||||
];
|
||||
const novels = Object.keys(allData.body.novels);
|
||||
const searchParams = new URLSearchParams();
|
||||
novels.forEach((novel) => {
|
||||
searchParams.append('ids[]', novel);
|
||||
});
|
||||
|
||||
const { data } = await got(`${baseUrl}/ajax/user/${id}/profile/novels`, {
|
||||
headers: {
|
||||
referer: url,
|
||||
},
|
||||
searchParams,
|
||||
});
|
||||
|
||||
const items = Object.values(data.body.works).map((item) => ({
|
||||
title: item.seriesTitle || item.title,
|
||||
description: item.description || item.title,
|
||||
link: `${baseUrl}/novel/series/${item.id}`,
|
||||
author: item.userName,
|
||||
pubDate: parseDate(item.createDate),
|
||||
updated: parseDate(item.updateDate),
|
||||
category: item.tags,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${data.body.novelSeries[0].userName || data.body.pickup[0].userName} 的小说`,
|
||||
link: `${baseUrl}/users/${id}/novels`,
|
||||
title: data.body.extraData.meta.title,
|
||||
description: data.body.extraData.meta.ogp.description,
|
||||
image: Object.values(data.body.works)[0].profileImageUrl,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue