diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml index 30ca9f286..9649364bc 100644 --- a/.github/workflows/clean.yml +++ b/.github/workflows/clean.yml @@ -10,7 +10,8 @@ jobs: strategy: fail-fast: false matrix: - country: [ + country: + [ ad, ae, af, @@ -166,8 +167,8 @@ jobs: vn, xk, ye, - zm - # unsorted + zm, + unsorted ] steps: - name: Checkout diff --git a/scripts/clean.js b/scripts/clean.js index 2288af620..9b4bd2095 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -17,6 +17,7 @@ program const config = program.opts() +const offlineStatusCodes = [404, 410, 500, 501] const instance = axios.create({ timeout: config.timeout, maxContentLength: 200000, @@ -24,7 +25,7 @@ const instance = axios.create({ rejectUnauthorized: false }), validateStatus: function (status) { - return status !== 404 + return !offlineStatusCodes.includes(status) } }) @@ -34,7 +35,7 @@ const stats = { broken: 0 } async function main() { console.info(`\nStarting...`) - console.time('Process completed in') + console.time('Done in') if (config.debug) { console.info(chalk.yellow(`INFO: Debug mode enabled\n`)) } @@ -101,12 +102,11 @@ async function checkStatus(playlist) { .then(utils.sleep(config.delay)) .catch(err => { clearTimeout(timeout) - if (err.response && err.response.status === 404) { - //console.error(err) + if (err.response && offlineStatusCodes.includes(err.response.status)) { if (config.debug) { console.info(` ${counter} ${chalk.red('offline')} ${chalk.white(channel.url)}`) - stats.broken++ } + stats.broken++ } else { results.push(channel) if (config.debug) { @@ -131,7 +131,7 @@ async function savePlaylist(playlist) { return false } else { utils.createFile(playlist.url, output) - console.info(`Playlist has been updated. Removed ${stats.broken} broken links.`) + console.info(`Playlist has been updated. Removed ${stats.broken} links.`) } return true @@ -142,7 +142,7 @@ async function done() { } function finish() { - console.timeEnd('Process completed in') + console.timeEnd('Done in') } main()