From 1f2827f51a42d44d9a08e5c257205dfc990b262e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 8 Sep 2021 21:04:38 +0300 Subject: [PATCH] Update sort.js --- scripts/sort.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/sort.js b/scripts/sort.js index 17560b8482..976dfcae01 100644 --- a/scripts/sort.js +++ b/scripts/sort.js @@ -1,16 +1,18 @@ const parser = require('./helpers/parser') const utils = require('./helpers/utils') +const file = require('./helpers/file') const log = require('./helpers/log') async function main() { log.start() - log.print(`Parsing 'index.m3u'...`) - let playlists = parser.parseIndex().filter(i => i.url !== 'channels/unsorted.m3u') - for (const playlist of playlists) { - log.print(`\nProcessing '${playlist.url}'...`) + let files = await file.list() + if (!files.length) log.print(`No files is selected\n`) + files = files.filter(file => file !== 'channels/unsorted.m3u') + for (const file of files) { + log.print(`\nProcessing '${file}'...`) await parser - .parsePlaylist(playlist.url) + .parsePlaylist(file) .then(sortChannels) .then(p => p.save()) }