From c11ce03a5c931f4548950052df1ef84dbfa180d8 Mon Sep 17 00:00:00 2001 From: freearhey Date: Wed, 20 Jan 2021 01:02:40 +0300 Subject: [PATCH] Update format.js --- scripts/format.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index 397ffee27..a7364feb0 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -5,11 +5,10 @@ const ProgressBar = require('progress') const https = require('https') program - .version('1.0.0', '-v, --version') .usage('[OPTIONS]...') .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('-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) @@ -27,7 +26,6 @@ const instance = axios.create({ }) let globalBuffer = [] -let bar async function main() { const index = parseIndex() @@ -109,7 +107,7 @@ async function removeDuplicates(playlist) { async function detectResolution(playlist) { if (!config.resolution) return playlist - bar = new ProgressBar(' Detecting resolution: [:bar] :current/:total (:percent) ', { + const bar = new ProgressBar(' Detecting resolution: [:bar] :current/:total (:percent) ', { total: playlist.items.length }) const results = [] @@ -118,7 +116,7 @@ async function detectResolution(playlist) { const url = item.url const response = await instance .get(url) - .then(sleep(config.delay)) + .then(helper.sleep(config.delay)) .catch(err => {}) if (response) { if (response.status === 200) { @@ -198,12 +196,6 @@ async function removeUnsortedDuplicates(playlist) { return playlist } -function sleep(ms) { - return function (x) { - return new Promise(resolve => setTimeout(() => resolve(x), ms)) - } -} - async function updatePlaylist(playlist) { const original = helper.readFile(playlist.url) let output = playlist.getHeader()