Remove epg parser

This commit is contained in:
freearhey 2021-03-06 21:22:23 +03:00
parent b7b01ad92f
commit 80f3518d57
5 changed files with 0 additions and 132 deletions

46
package-lock.json generated
View File

@ -8,7 +8,6 @@
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"commander": "^7.0.0", "commander": "^7.0.0",
"epg-parser": "^0.1.2",
"escape-string-regexp": "^2.0.0", "escape-string-regexp": "^2.0.0",
"iptv-playlist-parser": "^0.5.4", "iptv-playlist-parser": "^0.5.4",
"iso-639-3": "^2.0.0", "iso-639-3": "^2.0.0",
@ -94,14 +93,6 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
}, },
"node_modules/epg-parser": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/epg-parser/-/epg-parser-0.1.2.tgz",
"integrity": "sha512-q2vv1X3O6uCyJQhCGYXY5LtxKBdgG9b6lElNxbryqca/w2RlRALI9yMlQjtzAP+KYxrOuk/ekvsS/fdbLgDAIA==",
"dependencies": {
"xml-js": "^1.6.11"
}
},
"node_modules/escalade": { "node_modules/escalade": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
@ -180,11 +171,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"node_modules/string-width": { "node_modules/string-width": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
@ -240,17 +226,6 @@
"url": "https://github.com/chalk/wrap-ansi?sponsor=1" "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
} }
}, },
"node_modules/xml-js": {
"version": "1.6.11",
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
"dependencies": {
"sax": "^1.2.4"
},
"bin": {
"xml-js": "bin/cli.js"
}
},
"node_modules/y18n": { "node_modules/y18n": {
"version": "5.0.5", "version": "5.0.5",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
@ -347,14 +322,6 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
}, },
"epg-parser": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/epg-parser/-/epg-parser-0.1.2.tgz",
"integrity": "sha512-q2vv1X3O6uCyJQhCGYXY5LtxKBdgG9b6lElNxbryqca/w2RlRALI9yMlQjtzAP+KYxrOuk/ekvsS/fdbLgDAIA==",
"requires": {
"xml-js": "^1.6.11"
}
},
"escalade": { "escalade": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
@ -408,11 +375,6 @@
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
}, },
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"string-width": { "string-width": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
@ -449,14 +411,6 @@
"strip-ansi": "^6.0.0" "strip-ansi": "^6.0.0"
} }
}, },
"xml-js": {
"version": "1.6.11",
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
"requires": {
"sax": "^1.2.4"
}
},
"y18n": { "y18n": {
"version": "5.0.5", "version": "5.0.5",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",

View File

@ -9,7 +9,6 @@
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"commander": "^7.0.0", "commander": "^7.0.0",
"epg-parser": "^0.1.2",
"escape-string-regexp": "^2.0.0", "escape-string-regexp": "^2.0.0",
"iptv-playlist-parser": "^0.5.4", "iptv-playlist-parser": "^0.5.4",
"iso-639-3": "^2.0.0", "iso-639-3": "^2.0.0",

View File

@ -11,7 +11,6 @@ program
.option('-d, --debug', 'Debug mode') .option('-d, --debug', 'Debug mode')
.option('-c, --country <country>', 'Comma-separated list of country codes', '') .option('-c, --country <country>', 'Comma-separated list of country codes', '')
.option('-e, --exclude <exclude>', 'Comma-separated list of country codes to be excluded', '') .option('-e, --exclude <exclude>', 'Comma-separated list of country codes to be excluded', '')
.option('--epg', 'Turn on EPG parser')
.option('--resolution', 'Turn on resolution parser') .option('--resolution', 'Turn on resolution parser')
.option('--delay <delay>', 'Delay between parser requests', 0) .option('--delay <delay>', 'Delay between parser requests', 0)
.option('--timeout <timeout>', 'Set timeout for each request', 5000) .option('--timeout <timeout>', 'Set timeout for each request', 5000)
@ -39,7 +38,6 @@ async function main() {
.then(filterChannels) .then(filterChannels)
.then(removeDuplicates) .then(removeDuplicates)
.then(detectResolution) .then(detectResolution)
.then(updateFromEPG)
.then(savePlaylist) .then(savePlaylist)
.then(done) .then(done)
} }
@ -161,40 +159,6 @@ function parseResolution(string) {
: undefined : undefined
} }
async function updateFromEPG(playlist) {
if (!config.epg) return playlist
const tvgUrl = playlist.header.attrs['x-tvg-url']
if (!tvgUrl) return playlist
console.info(` Adding data from '${tvgUrl}'...`)
return utils
.parseEPG(tvgUrl)
.then(epg => {
if (!epg) return playlist
playlist.channels.map(channel => {
if (!channel.tvg.id) return channel
const epgItem = epg.channels[channel.tvg.id]
if (!epgItem) return channel
if (!channel.tvg.name && epgItem.name.length) {
channel.tvg.name = epgItem.name[0].value
}
if (!channel.languages.length && epgItem.name.length && epgItem.name[0].lang) {
channel.languages = utils.parseLanguages(epgItem.name[0].lang)
}
if (!channel.logo && epgItem.icon.length) {
channel.logo = epgItem.icon[0]
}
})
return playlist
})
.catch(err => {
console.log(`Error: EPG could not be loaded`)
})
}
async function removeUnsortedDuplicates(playlist) { async function removeUnsortedDuplicates(playlist) {
console.info(` Looking for duplicates...`) console.info(` Looking for duplicates...`)
const urls = globalBuffer.map(i => i.url.replace(/(^\w+:|^)\/\//, '')) const urls = globalBuffer.map(i => i.url.replace(/(^\w+:|^)\/\//, ''))

View File

@ -1,5 +1,4 @@
const playlistParser = require('iptv-playlist-parser') const playlistParser = require('iptv-playlist-parser')
const epgParser = require('epg-parser')
const utils = require('./utils') const utils = require('./utils')
const categories = require('./categories') const categories = require('./categories')
const path = require('path') const path = require('path')
@ -22,18 +21,6 @@ parser.parsePlaylist = function (filename) {
return new Playlist({ header: result.header, items: result.items, url: filename, country, name }) return new Playlist({ header: result.header, items: result.items, url: filename, country, name })
} }
parser.parseEPG = async function (url) {
return utils.loadEPG(url).then(content => {
const result = epgParser.parse(content)
const channels = {}
for (let channel of result.channels) {
channels[channel.id] = channel
}
return { url, channels }
})
}
class Playlist { class Playlist {
constructor({ header, items, url, name, country }) { constructor({ header, items, url, name, country }) {
this.url = url this.url = url

View File

@ -94,42 +94,6 @@ utils.sortBy = function (arr, fields) {
}) })
} }
utils.loadEPG = function (url) {
return new Promise((resolve, reject) => {
var buffer = []
axios({
method: 'get',
url: url,
responseType: 'stream',
timeout: 60000
})
.then(res => {
let stream
if (/\.gz$/i.test(url)) {
let gunzip = zlib.createGunzip()
res.data.pipe(gunzip)
stream = gunzip
} else {
stream = res.data
}
stream
.on('data', function (data) {
buffer.push(data.toString())
})
.on('end', function () {
resolve(buffer.join(''))
})
.on('error', function (e) {
reject(e)
})
})
.catch(e => {
reject(e)
})
})
}
utils.getBasename = function (filename) { utils.getBasename = function (filename) {
return path.basename(filename, path.extname(filename)) return path.basename(filename, path.extname(filename))
} }