Hotfix: tencent video (#1144)

Closes #1135
This commit is contained in:
凉凉 2018-11-14 14:21:46 +08:00 committed by DIYgod
parent 2b26dcced5
commit cb5980181f
1 changed files with 18 additions and 15 deletions

View File

@ -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: `
<iframe frameborder="0" src="https://v.qq.com/txp/iframe/player.html?vid=${video.id}" allowFullScreen="true"></iframe>
`,
}));
ctx.state.data = {
title: $('title').text(),
link,