From bde30c00106ac9d8043e4b5f15942536a14de1de Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 11 Mar 2022 18:38:30 +0300 Subject: [PATCH] Update cleaner.js --- scripts/commands/playlist/cleaner.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/commands/playlist/cleaner.js b/scripts/commands/playlist/cleaner.js index 2de731252..1eb623383 100644 --- a/scripts/commands/playlist/cleaner.js +++ b/scripts/commands/playlist/cleaner.js @@ -13,7 +13,9 @@ async function main() { for (const filepath of files) { if (!filepath.endsWith('.m3u')) continue + logger.info(`${filepath}`) const playlist = await parser.parsePlaylist(filepath) + const before = playlist.items.length for (const stream of playlist.items) { const [_, status] = stream.raw.match(/status="([a-z]+)"/) || [null, null] stream.status = status @@ -22,6 +24,7 @@ async function main() { const newStatus = parseStatus(result.error) if (status === newStatus) { stream.remove = true + logger.info(`removed "${stream.name}"`) } } } @@ -42,8 +45,11 @@ async function main() { } })) - const output = m3u.create(items) - await file.create(filepath, output) + if (before !== items.length) { + const output = m3u.create(items) + await file.create(filepath, output) + logger.info(`saved`) + } } }