wip
This commit is contained in:
parent
22d6ff0800
commit
de0a556554
|
@ -1,6 +1,6 @@
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const M3U8FileParser = require('m3u8-file-parser')
|
const parser = require('iptv-playlist-parser')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const zlib = require("zlib")
|
const zlib = require("zlib")
|
||||||
const DOMParser = require('xmldom').DOMParser
|
const DOMParser = require('xmldom').DOMParser
|
||||||
|
@ -65,24 +65,10 @@ class Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePlaylist(filename) {
|
function parsePlaylist(filename) {
|
||||||
const parser = new M3U8FileParser()
|
|
||||||
const content = readFile(filename)
|
const content = readFile(filename)
|
||||||
parser.read(content)
|
const result = parser.parse(content)
|
||||||
let results = parser.getResult()
|
|
||||||
let contentMatches = content.match(/^.+(?=#|\n|\r)/g)
|
|
||||||
let head = contentMatches.length ? contentMatches[0] : null
|
|
||||||
let attrs = {}
|
|
||||||
if(head) {
|
|
||||||
const parts = head.split(' ').filter(p => p !== '#EXTM3U').filter(p => p)
|
|
||||||
|
|
||||||
for(const attr of parts) {
|
console.log(result)
|
||||||
let attrParts = attr.split('=')
|
|
||||||
|
|
||||||
attrs[attrParts[0]] = attrParts[1].replace(/\"/g, '')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
results.attrs = attrs
|
|
||||||
|
|
||||||
return new Playlist({
|
return new Playlist({
|
||||||
attrs: results.attrs,
|
attrs: results.attrs,
|
||||||
|
|
Loading…
Reference in New Issue