feat: add 西瓜视频 (#6258)

This commit is contained in:
FlashWingShadow 2020-12-04 23:43:13 +08:00 committed by GitHub
parent b20a02428e
commit 43afea73a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 0 deletions

View File

@ -703,6 +703,18 @@ pageClass: routes
<Route author="magic-akari" example="/ncm/djradio/347317067" path="/ncm/djradio/:id" :paramsDesc="['节目 id, 可在电台节目页 URL 中找到']" supportPodcast="1" />
## 西瓜视频
::: tip Tiny Tiny RSS 用户请注意
Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性,导致无法加载西瓜视频内嵌视频,如果需要使用内嵌视频请为 Tiny Tiny RSS 安装 [remove_iframe_sandbox](https://github.com/DIYgod/ttrss-plugin-remove-iframe-sandbox) 插件
:::
### 用户视频投稿
<Route author="FlashWingShadow" example="/ixigua/user/video/4234740937" path="/ixigua/user/video/:uid/:disableEmbed?" :paramsDesc="['用户 id, 可在用户主页中找到', '默认为开启内嵌视频, 任意值为关闭']"/>
## 喜马拉雅
### 专辑

View File

@ -3595,6 +3595,9 @@ router.get('/youdao/latest', require('./routes/youdao/latest'));
router.get('/yinxiang/note', require('./routes/yinxiang/note'));
router.get('/yinxiang/card/:id?', require('./routes/yinxiang/card'));
// 西瓜视频
router.get('/ixigua/user/video/:uid/:disableEmbed?', require('./routes/ixigua/userVideo'));
// 遠見 gvm.com.tw
router.get('/gvm/index/:category?', require('./routes/gvm/index'));

View File

@ -0,0 +1,35 @@
const got = require('@/utils/got');
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 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}`);
}
if (jsonData.data.data.length === 0) {
throw Error('xigua video API: data is empty');
}
const videoInfos = jsonData.data.data;
const userInfo = videoInfos[0].user_info;
ctx.state.data = {
title: `${userInfo.name} 的西瓜视频`,
link: `${homeUrl}/home/${uid}`,
description: userInfo.author_desc,
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>`) +
`<img src="${i.middle_image.url}" /><p>${i.abstract}</p>`,
link: `${homeUrl}/${i.gid}`,
pubDate: i.publish_time * 1000,
author: userInfo.name,
})),
};
};