mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-02-10 22:15:12 +08:00
读取m3u文件
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
"express": "^4.17.1",
|
||||
"fast-xml-parser": "^3.17.4",
|
||||
"html2canvas": "^1.0.0-rc.5",
|
||||
"m3u8": "0.0.10",
|
||||
"modern-normalize": "^0.6.0",
|
||||
"mousetrap": "^1.6.5",
|
||||
"qrcode.vue": "^1.7.0",
|
||||
|
||||
@@ -183,8 +183,7 @@ export default {
|
||||
const options = {
|
||||
filters: [
|
||||
{ name: 'JSON file', extensions: ['json'] },
|
||||
{ name: 'Normal text file', extensions: ['txt'] },
|
||||
{ name: 'All types', extensions: ['*'] }
|
||||
{ name: 'm3u file', extensions: ['m3u'] }
|
||||
],
|
||||
properties: ['openFile']
|
||||
}
|
||||
@@ -192,14 +191,29 @@ export default {
|
||||
if (!result.canceled) {
|
||||
iptv.clear()
|
||||
result.filePaths.forEach(file => {
|
||||
var str = fs.readFileSync(file)
|
||||
const json = JSON.parse(str)
|
||||
iptv.bulkAdd(json).then(e => {
|
||||
this.getAllSites()
|
||||
})
|
||||
this.$message.success('导入成功')
|
||||
}).catch(err => {
|
||||
this.$message.error(err)
|
||||
if (file.endsWith('json')) {
|
||||
var str = fs.readFileSync(file)
|
||||
const json = JSON.parse(str)
|
||||
iptv.bulkAdd(json).then(e => {
|
||||
this.getAllSites()
|
||||
})
|
||||
this.$message.success('导入成功')
|
||||
} else if (file.endsWith('m3u')) {
|
||||
var m3u8 = require('m3u8')
|
||||
var parser = m3u8.createStream()
|
||||
var m3ufile = fs.createReadStream(file)
|
||||
m3ufile.pipe(parser)
|
||||
parser.on('item', function (item) {
|
||||
var prop = item.properties
|
||||
if (prop.title && prop.uri && prop.uri.endsWith('m3u8')) {
|
||||
var doc = {
|
||||
name: prop.title,
|
||||
url: prop.uri
|
||||
}
|
||||
iptv.add(doc)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -298,6 +298,7 @@ export default {
|
||||
}
|
||||
|
||||
if (this.video.info.url) {
|
||||
// 如果info里含有有url,是直播源,直接播放
|
||||
this.playUrl(this.video.info.url)
|
||||
} else {
|
||||
const index = this.video.info.index | 0
|
||||
@@ -313,7 +314,6 @@ export default {
|
||||
}
|
||||
},
|
||||
playUrl (url) {
|
||||
this.$message.success(url)
|
||||
this.xg.src = url
|
||||
this.xg.play()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user