From 80f3518d57f1ee012a6c70a9aa3ca5df6b470068 Mon Sep 17 00:00:00 2001 From: freearhey Date: Sat, 6 Mar 2021 21:22:23 +0300 Subject: [PATCH] Remove epg parser --- package-lock.json | 46 ---------------------------------------------- package.json | 1 - scripts/format.js | 36 ------------------------------------ scripts/parser.js | 13 ------------- scripts/utils.js | 36 ------------------------------------ 5 files changed, 132 deletions(-) diff --git a/package-lock.json b/package-lock.json index 394d1286b3..e7c20f6de9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,6 @@ "dependencies": { "axios": "^0.21.1", "commander": "^7.0.0", - "epg-parser": "^0.1.2", "escape-string-regexp": "^2.0.0", "iptv-playlist-parser": "^0.5.4", "iso-639-3": "^2.0.0", @@ -94,14 +93,6 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "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": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -180,11 +171,6 @@ "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": { "version": "4.2.2", "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" } }, - "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": { "version": "5.0.5", "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", "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": { "version": "3.1.1", "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", "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": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", @@ -449,14 +411,6 @@ "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": { "version": "5.0.5", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", diff --git a/package.json b/package.json index 08e9857e37..2d2e7fff9b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "dependencies": { "axios": "^0.21.1", "commander": "^7.0.0", - "epg-parser": "^0.1.2", "escape-string-regexp": "^2.0.0", "iptv-playlist-parser": "^0.5.4", "iso-639-3": "^2.0.0", diff --git a/scripts/format.js b/scripts/format.js index 69b2a17e77..c9e76a55e1 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -11,7 +11,6 @@ program .option('-d, --debug', 'Debug mode') .option('-c, --country ', 'Comma-separated list of country codes', '') .option('-e, --exclude ', 'Comma-separated list of country codes to be excluded', '') - .option('--epg', 'Turn on EPG parser') .option('--resolution', 'Turn on resolution parser') .option('--delay ', 'Delay between parser requests', 0) .option('--timeout ', 'Set timeout for each request', 5000) @@ -39,7 +38,6 @@ async function main() { .then(filterChannels) .then(removeDuplicates) .then(detectResolution) - .then(updateFromEPG) .then(savePlaylist) .then(done) } @@ -161,40 +159,6 @@ function parseResolution(string) { : 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) { console.info(` Looking for duplicates...`) const urls = globalBuffer.map(i => i.url.replace(/(^\w+:|^)\/\//, '')) diff --git a/scripts/parser.js b/scripts/parser.js index 71212b4376..3a53eccbfc 100644 --- a/scripts/parser.js +++ b/scripts/parser.js @@ -1,5 +1,4 @@ const playlistParser = require('iptv-playlist-parser') -const epgParser = require('epg-parser') const utils = require('./utils') const categories = require('./categories') 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 }) } -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 { constructor({ header, items, url, name, country }) { this.url = url diff --git a/scripts/utils.js b/scripts/utils.js index 4d4e053f40..5eb6cdba81 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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) { return path.basename(filename, path.extname(filename)) }