From 746c93c9d24c947891952100b30fe95b79f905e4 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Mon, 28 Sep 2020 20:53:15 +0200 Subject: [PATCH] =?UTF-8?q?=E6=A8=B1=E8=8A=B1=E5=8A=A8=E6=BC=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/site/onlineVideo.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/lib/site/onlineVideo.js b/src/lib/site/onlineVideo.js index 4b27a2b..580f936 100644 --- a/src/lib/site/onlineVideo.js +++ b/src/lib/site/onlineVideo.js @@ -108,6 +108,42 @@ const onlineVideo = { }) } }) + }, + playVideoOnYhdm (videoName, videoIndex) { + videoName = videoName.replace(/\s/g, '') + var url = `http://www.yhdm.tv/search/${videoName}` + axios.get(url).then(res => { + const $ = cheerio.load(res.data) + var e = $('div.lpic') + var searchResult = $(e).find('div>ul>li>h2>a').toArray() + // 获取第一个搜索结果的视频链接 + var detailPageLink = $(searchResult[0]).attr('href') + // 获取第一个搜索结果的title + var title = $(searchResult[0]).attr('title') + if (title === null || title === undefined || !title.replace(/\s/g, '').includes(videoName)) { + // 如果第一个搜索结果不符合,打开搜索页面 + open(url) + } else { + // 解析详情页面 + var detailPageFullLink = 'http://www.yhdm.tv/' + detailPageLink + axios.get(detailPageFullLink).then(res2 => { + const $ = cheerio.load(res2.data) + // 获取playlist1 + var e = $('div.movurl') + // 获取所有视频链接 + var videoList = $(e).find('div>ul>li>a').toArray() + // 获取index视频链接 + var videoFullLink = detailPageFullLink + if (videoIndex < videoList.length) { + var indexVideoLink = $(videoList[videoIndex]).attr('href') + if (indexVideoLink.includes('.htm')) { + videoFullLink = 'http://www.yhdm.tv/' + indexVideoLink + } + } + open(videoFullLink) + }) + } + }) } } export default onlineVideo