Skip to content

Commit

Permalink
route(fix): Update userVideo.js (DIYgod#7405)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunyu950908 authored May 12, 2021
1 parent f2c506d commit cf38a0c
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit cf38a0c

Please sign in to comment.