From 60cc2dab6f875d62b9fc2927d34f419b3fc32464 Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 9 Aug 2019 13:52:54 +0300 Subject: [PATCH] Update util.js Replaced https package with axios (resolve 'wrong protocol' issue) --- helpers/util.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/helpers/util.js b/helpers/util.js index c33569299..38ac4637b 100644 --- a/helpers/util.js +++ b/helpers/util.js @@ -1,7 +1,7 @@ const fs = require("fs") const path = require('path') const M3U8FileParser = require('m3u8-file-parser') -const https = require("https") +const axios = require('axios') const zlib = require("zlib") const DOMParser = require('xmldom').DOMParser const urlParser = require('url') @@ -132,9 +132,13 @@ async function loadEPG(url) { function getGzipped(url) { return new Promise((resolve, reject) => { var buffer = [] - https.get(url, function(res) { + axios({ + method: 'get', + url: url, + responseType:'stream' + }).then(res => { var gunzip = zlib.createGunzip() - res.pipe(gunzip) + res.data.pipe(gunzip) gunzip.on('data', function(data) { buffer.push(data.toString()) }).on("end", function() { @@ -142,7 +146,7 @@ function getGzipped(url) { }).on("error", function(e) { reject(e) }) - }).on('error', function(e) { + }).catch(e => { reject(e) }) })