From 43afea73a2138e320dd5997302d53a2ecb06b62a Mon Sep 17 00:00:00 2001 From: FlashWingShadow <45242683+FlashWingShadow@users.noreply.github.com> Date: Fri, 4 Dec 2020 23:43:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E8=A5=BF=E7=93=9C=E8=A7=86?= =?UTF-8?q?=E9=A2=91=20(#6258)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 12 ++++++++++++ lib/router.js | 3 +++ lib/routes/ixigua/userVideo.js | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 lib/routes/ixigua/userVideo.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 2569ab460..67f1a6c39 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -703,6 +703,18 @@ pageClass: routes +## 西瓜视频 + +::: 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) 插件 + +::: + +### 用户视频投稿 + + + ## 喜马拉雅 ### 专辑 diff --git a/lib/router.js b/lib/router.js index 48005cb70..8877f6c06 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/ixigua/userVideo.js b/lib/routes/ixigua/userVideo.js new file mode 100644 index 000000000..95390c962 --- /dev/null +++ b/lib/routes/ixigua/userVideo.js @@ -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 ? '' : `
`) + + `

${i.abstract}

`, + link: `${homeUrl}/${i.gid}`, + pubDate: i.publish_time * 1000, + author: userInfo.name, + })), + }; +};