mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-05 19:53:22 +08:00
获取全部视频提供的视频列表,为兼容目的,zy.detail函数仍返回m3u8List和mp4List, 会在后续工作中陆续删除
This commit is contained in:
@@ -52,10 +52,16 @@
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="desc" v-show="info.des">{{info.des}}</div>
|
||||
class="desc" v-show="info.des">{{info.des}}
|
||||
</div>
|
||||
<div class="m3u8" v-if="videoFullList.length > 1">
|
||||
<div class="box">
|
||||
<span v-for="(i, j) in videoFullList" :key="j" @click="updateVideoList(i)">{{i.flag}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m3u8">
|
||||
<div class="box">
|
||||
<span v-for="(i, j) in m3u8List" :key="j" @click="playEvent(j)">{{i | ftName}}</span>
|
||||
<span v-for="(i, j) in videoList" :key="j" @click="playEvent(j)">{{i | ftName}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user