From b442162ecdae1128e9c78dc8339784d423e8d66e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 8 Sep 2021 20:52:57 +0300 Subject: [PATCH] Update remove-broken-links.js --- scripts/remove-broken-links.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/remove-broken-links.js b/scripts/remove-broken-links.js index 3faf9968b3..a6fff7a85c 100644 --- a/scripts/remove-broken-links.js +++ b/scripts/remove-broken-links.js @@ -1,15 +1,17 @@ const parser = require('./helpers/parser') +const file = require('./helpers/file') const log = require('./helpers/log') async function main() { log.start() - log.print(`Parsing 'index.m3u'...`) - const 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(removeBrokenLinks) .then(p => p.save()) }