mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-09 15:52:40 +08:00
修复无法正确导入直播源的问题
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
"express": "^4.17.1",
|
||||
"fast-xml-parser": "^3.17.4",
|
||||
"html2canvas": "^1.0.0-rc.5",
|
||||
"m3u8": "0.0.10",
|
||||
"iptv-playlist-parser": "^0.5.0",
|
||||
"modern-normalize": "^0.6.0",
|
||||
"mousetrap": "^1.6.5",
|
||||
"qrcode.vue": "^1.7.0",
|
||||
|
||||
@@ -200,27 +200,29 @@ export default {
|
||||
})
|
||||
})
|
||||
} else if (file.endsWith('m3u')) {
|
||||
var m3u8 = require('m3u8')
|
||||
var parser = m3u8.createStream()
|
||||
var m3ufile = fs.createReadStream(file, { encoding: 'utf-8' })
|
||||
m3ufile.pipe(parser)
|
||||
const parser = require('iptv-playlist-parser')
|
||||
const playlist = fs.readFileSync(file, { encoding: 'utf-8' })
|
||||
const result = parser.parse(playlist)
|
||||
var docs = []
|
||||
parser.on('item', function (item) {
|
||||
var prop = item.properties
|
||||
if (prop.title && prop.uri && prop.uri.endsWith('m3u8')) {
|
||||
result.items.forEach(ele => {
|
||||
if (ele.name && ele.url && ele.url.endsWith('m3u8')) {
|
||||
var doc = {
|
||||
name: prop.title,
|
||||
url: prop.uri
|
||||
name: ele.name,
|
||||
url: ele.url
|
||||
}
|
||||
docs.push(doc)
|
||||
}
|
||||
})
|
||||
iptv.clear().then(res => {
|
||||
iptv.bulkAdd(docs).then(e => {
|
||||
this.getAllSites()
|
||||
this.$message.success('导入成功')
|
||||
if (docs) {
|
||||
iptv.clear().then(res => {
|
||||
iptv.bulkAdd(docs).then(e => {
|
||||
this.getAllSites()
|
||||
this.$message.success('导入成功')
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.$message.error('m3u文件没有读取到可用源数据')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user