From 745fe395b494da0fe757f4f13752228962f546f5 Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 00:35:55 +0300 Subject: [PATCH] Remove test.js Has been replaced by clean.js --- package.json | 3 +- scripts/test.js | 80 ------------------------------------------------- 2 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 scripts/test.js diff --git a/package.json b/package.json index 353f613052..b8f6513439 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,7 @@ { "name": "iptv", "scripts": { - "lint": "npx m3u-linter -c m3u-linter.json", - "test": "node scripts/test.js" + "lint": "npx m3u-linter -c m3u-linter.json" }, "pre-push": [ "lint" diff --git a/scripts/test.js b/scripts/test.js deleted file mode 100644 index d46c58dd33..0000000000 --- a/scripts/test.js +++ /dev/null @@ -1,80 +0,0 @@ -const { program } = require('commander') -const utils = require('./utils') -const parser = require('./parser') -const axios = require('axios') -const https = require('https') -const ProgressBar = require('progress') - -program - .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('--delay ', 'Delay between parser requests', 1000) - .option('--timeout ', 'Set timeout for each request', 60000) - .parse(process.argv) - -const config = program.opts() - -const instance = axios.create({ - timeout: config.timeout, - maxContentLength: 200000, - httpsAgent: new https.Agent({ - rejectUnauthorized: false - }), - validateStatus: function (status) { - return (status >= 200 && status < 300) || status === 403 - } -}) - -let stats = { - playlists: 0, - channels: 0, - failures: 0 -} - -async function test() { - let items = parser.parseIndex() - items = utils.filterPlaylists(items, config.country, config.exclude) - - for (const item of items) { - const playlist = parser.parsePlaylist(item.url) - const bar = new ProgressBar(`Processing '${item.url}'...:current/:total`, { - total: playlist.channels.length - }) - - stats.playlists++ - - for (let channel of playlist.channels) { - bar.tick() - stats.channels++ - - if (channel.url.startsWith('rtmp://')) continue - - await instance - .get(channel.url) - .then(utils.sleep(config.delay)) - .catch(error => { - if (error.response) { - stats.failures++ - utils.writeToLog(item.url, error.message, channel.url) - } - }) - } - } - - if (stats.failures === 0) { - console.log(`\nOK (${stats.playlists} playlists, ${stats.channels} channels)`) - } else { - console.log( - `\nFAILURES! (${stats.playlists} playlists, ${stats.channels} channels, ${stats.failures} failures) - \n\nCheck the "error.log" file to see which links failed.` - ) - - process.exit(1) - } -} - -console.log('Test is running...\n') - -test()