From cb5980181fa9b0cead80ae85f6c5e021970bc68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Wed, 14 Nov 2018 14:21:46 +0800 Subject: [PATCH] Hotfix: tencent video (#1144) Closes #1135 --- routes/tencent/video/playlist.js | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/routes/tencent/video/playlist.js b/routes/tencent/video/playlist.js index 982a1efd0..6d4b414f1 100644 --- a/routes/tencent/video/playlist.js +++ b/routes/tencent/video/playlist.js @@ -1,22 +1,25 @@ const axios = require('../../../utils/axios'); const cheerio = require('cheerio'); + module.exports = async (ctx) => { - const id = ctx.params.id; + const { id } = ctx.params; const link = `https://v.qq.com/detail/${id[0]}/${id}.html`; - const { data } = await axios.get(link); - const $ = cheerio.load(data); - const episodeName = $('[itemprop=episodeNumber]') - .toArray() - .reverse() - .slice(0, 20); - const items = []; - for (const one of episodeName) { - const ele = $(one); - items.push({ - title: ele.text(), - link: ele.parent().attr('href'), - }); - } + const page = await axios.get(link); + const $ = cheerio.load(page.data); + const last = $('._tabsNav > .item') + .last() + .attr('data-range') + .split('-')[1]; + const episodes = await axios.get(`https://s.video.qq.com/get_playsource?id=${id}&plat=2&type=4&data_type=2&video_type=3&range=1-${last}&plname=qq&otype=json&num_mod_cnt=20&callback=a&_t=${Date.now()}`); + const playList = JSON.parse(episodes.data.slice(2, -1)).PlaylistItem.videoPlayList.reverse(); + const items = playList.map((video) => ({ + title: video.title, + link: video.playUrl, + description: ` + + `, + })); + ctx.state.data = { title: $('title').text(), link,