Update cleaner.js

This commit is contained in:
Aleksandr Statciuk 2022-03-11 19:10:49 +03:00
parent 17894e71fb
commit 02b27d247f
1 changed files with 4 additions and 1 deletions

View File

@ -1,13 +1,15 @@
const { file, parser, logger, checker, m3u } = require('../../core')
const { program } = require('commander')
const options = program
program
.argument('[filepath]', 'Path to file to validate')
.option('-t, --timeout <timeout>', 'Set timeout for each request', parser.parseNumber, 60000)
.option('-d, --delay <delay>', 'Set delay for each request', parser.parseNumber, 0)
.option('--debug', 'Enable debug mode')
.parse(process.argv)
const options = program.opts()
async function main() {
const files = program.args.length ? program.args : await file.list('streams/*.m3u')
@ -17,6 +19,7 @@ async function main() {
const playlist = await parser.parsePlaylist(filepath)
const before = playlist.items.length
for (const stream of playlist.items) {
if (options.debug) logger.info(stream.url)
const [_, status] = stream.raw.match(/status="([a-z]+)"/) || [null, null]
stream.status = status
if (status === 'error' && /^(http|https)/.test(stream.url) && !/\[.*\]$/.test(stream.name)) {