feat: fix tencent->video 更多链接支持 (#4563)

This commit is contained in:
talengu
2020-04-28 11:12:05 +08:00
committed by GitHub
parent 89aef16868
commit 1bb6cb51cf
3 changed files with 113 additions and 9 deletions

View File

@@ -6,15 +6,36 @@ module.exports = async (ctx) => {
const link = `https://v.qq.com/detail/${id[0]}/${id}.html`;
const page = await got.get(link);
const $ = cheerio.load(page.data);
const episodes = await got.get(`https://s.video.qq.com/get_playsource?id=${id}&plat=2&type=4&data_type=2&video_type=3&range=1&plname=qq&otype=json&num_mod_cnt=20&callback=a&_t=${Date.now()}`);
const playList = JSON.parse(episodes.data.slice(2, -1)).PlaylistItem.videoPlayList;
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>
`,
}));
let vtype = 4;
// 支持地址 https://v.qq.com/detail/8/84842.html
let items = null;
if (`${id[0]}` === '8') {
vtype = 1;
const episodes = await got.get(`https://s.video.qq.com/get_playsource?id=${id}&plat=2&type=${vtype}&data_type=2&video_type=3&range=1&plname=qq&otype=json&num_mod_cnt=20&callback=a&_t=${Date.now()}`);
const playList = JSON.parse(episodes.data.slice(2, -1)).playlist[0].videoPlayList;
items = playList.map(function (video) {
const video_id = video.playUrl.split('=')[1];
const info = {
title: video.title,
link: video.playUrl,
description: `
<iframe src="https://v.qq.com/txp/iframe/player.html?vid=${video_id}" allowFullScreen="true" width="640" height="430"></iframe>
`,
};
return info;
});
} else {
const episodes = await got.get(`https://s.video.qq.com/get_playsource?id=${id}&plat=2&type=${vtype}&data_type=2&video_type=3&range=1&plname=qq&otype=json&num_mod_cnt=20&callback=a&_t=${Date.now()}`);
const playList = JSON.parse(episodes.data.slice(2, -1)).PlaylistItem.videoPlayList;
items = playList.map((video) => ({
title: video.title,
link: video.playUrl,
description: `
<iframe src="https://v.qq.com/txp/iframe/player.html?vid=${video.id}" allowFullScreen="true" width="640" height="430"></iframe>
`,
}));
}
ctx.state.data = {
title: $('title').text(),