From 0cc330463f19ae7c38a5c164d3275202fbbdef8f Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Tue, 29 Dec 2020 22:04:52 +0100 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=85=A8=E9=83=A8=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=8F=90=E4=BE=9B=E7=9A=84=E8=A7=86=E9=A2=91=E5=88=97?= =?UTF-8?q?=E8=A1=A8,=E4=B8=BA=E5=85=BC=E5=AE=B9=E7=9B=AE=E7=9A=84,zy.deta?= =?UTF-8?q?il=E5=87=BD=E6=95=B0=E4=BB=8D=E8=BF=94=E5=9B=9Em3u8List?= =?UTF-8?q?=E5=92=8Cmp4List,=20=E4=BC=9A=E5=9C=A8=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=B8=AD=E9=99=86=E7=BB=AD=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Detail.vue | 30 +++++++++++++++++++++++------- src/components/Play.vue | 36 +++++++++++++----------------------- src/lib/site/tools.js | 18 +++++++++++++++--- 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/components/Detail.vue b/src/components/Detail.vue index 1b52905..e21917f 100644 --- a/src/components/Detail.vue +++ b/src/components/Detail.vue @@ -52,10 +52,16 @@
{{info.des}}
+ class="desc" v-show="info.des">{{info.des}} + +
+
+ {{i.flag}} +
+
- {{i | ftName}} + {{i | ftName}}
@@ -76,7 +82,9 @@ export default { data () { return { loading: true, - m3u8List: [], + videoFlag: '', + videoList: [], + videoFullList: [], info: {}, playOnline: false, selectedOnlineSite: '哔嘀', @@ -128,13 +136,17 @@ export default { close () { this.detail.show = false }, + updateVideoList (e) { + this.videoFlag = e.flag + this.videoList = e.list + }, async playEvent (n) { if (!this.playOnline) { const db = await history.find({ site: this.detail.key, ids: this.detail.info.id }) if (db) { - this.video = { key: db.site, info: { id: db.ids, name: db.name, index: n, site: this.detail.site } } + this.video = { key: db.site, info: { id: db.ids, name: db.name, index: n, site: this.detail.site, videoFlag: this.videoFlag } } } else { - this.video = { key: this.detail.key, info: { id: this.detail.info.id, name: this.detail.info.name, index: n, site: this.detail.site } } + this.video = { key: this.detail.key, info: { id: this.detail.info.id, name: this.detail.info.name, index: n, site: this.detail.site, videoFlag: this.videoFlag } } } this.video.detail = this.info this.view = 'Play' @@ -225,7 +237,8 @@ export default { this.$message.success('调用下载接口获取到的链接已复制, 快去下载吧!') } else { zy.detail(key, id).then(res => { - const list = [...res.m3u8List] + // 只使用第一个视频列表 + const list = [...res.fullList[0].list] let downloadUrl = '' for (const i of list) { const url = encodeURI(i.split('$')[1]) @@ -265,7 +278,10 @@ export default { if (res) { this.info = res this.$set(this.info, 'rate', '') - this.m3u8List = res.m3u8List + this.videoFlag = res.fullList[0].flag + this.videoList = res.fullList[0].list + this.videoFullList = res.fullList + console.log(this.videoFullList) this.getDoubanRate() this.loading = false } diff --git a/src/components/Play.vue b/src/components/Play.vue index 80e8531..9c0aea8 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -611,8 +611,15 @@ export default { playVideo (index = 0, time = 0) { this.isLive = false this.exportablePlaylist = false - this.fetchPlaylist().then(async (playlistUrls) => { - const url = playlistUrls[index] + this.fetchPlaylist().then(async (fullList) => { + // 默认播放第一个video flag下面的视频 + var playlistUrls = fullList[0].list + const videoFlag = this.video.info.videoFlag + // 如果设定了特定的video flag, 获取该flag下的视频列表 + if (videoFlag) { + playlistUrls = fullList.find(x => x.flag === videoFlag).list + } + var url = playlistUrls[index].split('$')[1] if (playlistUrls.every(e => e.endsWith('.m3u8'))) this.exportablePlaylist = true if (!url.endsWith('.m3u8') && !url.endsWith('.mp4')) { const currentSite = await sites.find({ key: this.video.key }) @@ -659,28 +666,11 @@ export default { } zy.detail(this.video.key, this.video.info.id).then(res => { this.name = res.name - const playlist = res.m3u8List.length ? res.m3u8List : res.mp4List - this.right.list = playlist - const playlistUrls = [] - for (const i of playlist) { - const j = i.split('$') - if (j.length > 1) { - for (let m = 0; m < j.length; m++) { - if (j[m].startsWith('http')) { - playlistUrls.push(j[m]) - break - } - } - } else { - playlistUrls.push(j[0]) - } - } - - VIDEO_DETAIL_CACHE[cacheKey] = Object.assign(VIDEO_DETAIL_CACHE[cacheKey] || {}, { - list: playlistUrls, + VIDEO_DETAIL_CACHE[cacheKey] = { + list: res.fullList, name: res.name - }) - resolve(playlistUrls) + } + resolve(res.fullList) }) }) }, diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index f28d165..dc4f081 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -239,25 +239,37 @@ const zy = { // Parse m3u8List var m3u8List = [] let mp4List = [] + // Parse video lists + var fullList = [] const dd = videoList.dl.dd const type = Object.prototype.toString.call(dd) if (type === '[object Array]') { for (const i of dd) { + fullList.push( + { + flag: i._flag, + list: i._t.split('#') + } + ) // 如果含有多个视频列表的话, 仅获取m3u8列表 if (i._flag.includes('m3u8') || i._t.includes('.m3u8')) { m3u8List = i._t.split('#') - break - // 获取不到m3u8时,尝试获取mp4列表 } else if (i._flag.includes('mp4') || i._t.includes('.mp4')) { mp4List = i._t.split('#') - break } } } else { + fullList.push( + { + flag: dd._flag, + list: dd._t.split('#') + } + ) m3u8List = dd._t.split('#') } videoList.m3u8List = m3u8List if (mp4List.length) videoList.mp4List = mp4List + videoList.fullList = fullList resolve(videoList) }).catch(err => { reject(err)