From b72c88dfb9a5b6933fab73fedcd950e51ae4d8db Mon Sep 17 00:00:00 2001 From: buvta <12312540+buvta@users.noreply.github.com> Date: Thu, 31 Dec 2020 14:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86ZY=E6=94=AF=E6=8C=81=E7=9A=84=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=88=97=E8=A1=A8=E5=89=8D=E7=BD=AE=E5=88=B0=E9=A6=96?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Play.vue | 4 +--- src/lib/site/tools.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/Play.vue b/src/components/Play.vue index 7df9926..98da1d0 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -613,13 +613,11 @@ export default { this.isLive = false this.exportablePlaylist = false this.fetchPlaylist().then(async (fullList) => { - var playlist = fullList[0].list + var playlist = fullList[0].list // ZY支持的已移到首位 // 如果设定了特定的video flag, 获取该flag下的视频列表 const videoFlag = this.video.info.videoFlag if (videoFlag) { playlist = fullList.find(x => x.flag === videoFlag).list - } else if (fullList.length > 1 && fullList.find(x => x.flag === 'm3u8' || x.flag === 'mp4')) { - playlist = fullList.find(x => x.flag === 'm3u8' || x.flag === 'mp4').list // 播放器支持的格式优先 } this.right.list = playlist var url = playlist[index].split('$')[1] diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index 72bf644..5a09354 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -240,12 +240,21 @@ const zy = { var m3u8List = [] // Parse video lists var fullList = [] + let index = 0 + const supportedFormats = ['m3u8', 'mp4'] const dd = videoList.dl.dd const type = Object.prototype.toString.call(dd) if (type === '[object Array]') { for (const i of dd) { - const ext = Array.from(new Set(...i._t.split('#').map(e => e.split('$')[1].match(/\.\w+?$/)))) - if (ext.length === 1) i._flag = ext[0].slice(1) + const ext = Array.from(new Set(...i._t.split('#').map(e => e.split('$')[1].match(/\.\w+?$/)))).map(e => e.slice(1)) + if (ext.length && ext.length <= supportedFormats.length && ext.every(e => supportedFormats.includes(e))) { + if (ext.length === 1) { + i._flag = ext[0] + } else { + i._flag = index ? 'ZY支持-' + index : 'ZY支持' + index++ + } + } fullList.push( { flag: i._flag, @@ -267,6 +276,13 @@ const zy = { m3u8List = dd._t.split('#') } videoList.m3u8List = m3u8List + if (fullList.length > 1) { // 将ZY支持的播放列表前置 + index = fullList.findIndex(e => supportedFormats.includes(e.flag) || e.flag.startsWith('ZY支持')) + if (index !== -1) { + const first = fullList.splice(index, 1) + fullList = first.concat(fullList) + } + } videoList.fullList = fullList resolve(videoList) }).catch(err => {