Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: userVideo.js ixigua api #7405

Merged
merged 1 commit into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/routes/ixigua/userVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ module.exports = async (ctx) => {
const uid = ctx.params.uid;
const disableEmbed = ctx.params.disableEmbed;
const homeUrl = 'https://www.ixigua.com';
const videoApiUrl = `${homeUrl}/api/videov2/author/video?&author_id=${uid}&type=video&max_time=0`;
const videoApiUrl = `${homeUrl}/api/videov2/author/new_video_list?&to_user_id=${uid}&offset=0&limit=20&order=new`;
const resp = await got(videoApiUrl, { headers: { referer: homeUrl } });
const jsonData = resp.data;

if (jsonData.code !== 200) {
throw Error(`xigua video API: code = ${jsonData.code}, message = ${jsonData.data.message}`);
throw Error(`xigua video API: code = ${jsonData.data.code}, message = ${jsonData.data.message}`);
}
if (jsonData.data.data.length === 0) {
throw Error('xigua video API: data is empty');
if (jsonData.data.videoList.length === 0) {
throw Error('xigua video API: videoList is empty');
}

const videoInfos = jsonData.data.data;
const videoInfos = jsonData.data.videoList;
const userInfo = videoInfos[0].user_info;

ctx.state.data = {
title: `${userInfo.name} 的西瓜视频`,
link: `${homeUrl}/home/${uid}`,
description: userInfo.author_desc,
description: userInfo.description,
item: videoInfos.map((i) => ({
title: i.title,
description:
(disableEmbed ? '' : `<iframe width="720" height="405" frameborder="0" allowfullscreen src="https://www.ixigua.com/iframe/${i.gid}?autoplay=0&startTime=0"></iframe><br>`) +
(disableEmbed ? '' : `<iframe width="720" height="405" frameborder="0" allowfullscreen src="https://www.ixigua.com/iframe/${i.gid}?autoplay=0" referrerpolicy="unsafe-url" allowfullscreen></iframe><br>`) +
`<img src="${i.middle_image.url}" /><p>${i.abstract}</p>`,
link: `${homeUrl}/${i.gid}`,
pubDate: i.publish_time * 1000,
Expand Down