Update format.js

This commit is contained in:
Aleksandr Statciuk 2021-09-08 20:46:27 +03:00
parent e51f10023a
commit 1b2fbcce3a

View File

@ -1,4 +1,3 @@
const glob = require('glob')
const IPTVChecker = require('iptv-checker') const IPTVChecker = require('iptv-checker')
const normalize = require('normalize-url') const normalize = require('normalize-url')
const { program } = require('commander') const { program } = require('commander')
@ -25,16 +24,15 @@ const checker = new IPTVChecker({
}) })
let buffer, origins let buffer, origins
function main() { async function main() {
log.start() log.start()
glob('channels/*.m3u', { ignore: ['unsorted.m3u'] }, handleFiles) const include = config.country.split(',').filter(i => i)
} const exclude = config.exclude.split(',').filter(i => i)
let files = await file.list(include, exclude)
async function handleFiles(er, files) { files = files.filter(file => file !== 'channels/unsorted.m3u')
const filtered = utils.filterFiles(files, config.country, config.exclude) if (!files.length) log.print(`No files is selected\n`)
if (!filtered.length) log.print(`No files is selected\n`) for (const file of files) {
for (const file of filtered) {
await parser.parsePlaylist(file).then(updatePlaylist).then(savePlaylist) await parser.parsePlaylist(file).then(updatePlaylist).then(savePlaylist)
} }