iptv/scripts/helpers/parser.js
Aleksandr Statciuk 39ab38d277 Update parser.js
2021-09-08 21:33:50 +03:00

21 lines
547 B
JavaScript

const playlistParser = require('iptv-playlist-parser')
const Playlist = require('./Playlist')
const utils = require('./utils')
const file = require('./file')
const parser = {}
parser.parsePlaylist = async function (url) {
const content = file.read(url)
const result = playlistParser.parse(content)
const filename = file.getFilename(url)
const country = {
code: filename,
name: utils.code2name(filename)
}
return new Playlist({ header: result.header, items: result.items, url, filename, country })
}
module.exports = parser