From c18bf41b38be701cba43d24de22ce573d6ac3b29 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Tue, 20 Jun 2023 09:23:10 +0300 Subject: [PATCH] Update validate.js --- scripts/commands/playlist/validate.js | 68 +++++++++++++++------------ 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/scripts/commands/playlist/validate.js b/scripts/commands/playlist/validate.js index 15ee4a73e..fe1959584 100644 --- a/scripts/commands/playlist/validate.js +++ b/scripts/commands/playlist/validate.js @@ -32,39 +32,47 @@ async function main() { const buffer = {} const fileLog = [] - const playlist = await parser.parsePlaylist(filepath) - for (const item of playlist.items) { - if (item.tvg.id && !api.channels.find({ id: item.tvg.id })) { - fileLog.push({ - type: 'warning', - line: item.line, - message: `"${item.tvg.id}" is not in the database` - }) - } + try { + const playlist = await parser.parsePlaylist(filepath) + for (const item of playlist.items) { + if (item.tvg.id && !api.channels.find({ id: item.tvg.id })) { + fileLog.push({ + type: 'warning', + line: item.line, + message: `"${item.tvg.id}" is not in the database` + }) + } - if (item.url && buffer[item.url]) { - fileLog.push({ - type: 'warning', - line: item.line, - message: `"${item.url}" is already on the playlist` - }) - } else { - buffer[item.url] = true - } + if (item.url && buffer[item.url]) { + fileLog.push({ + type: 'warning', + line: item.line, + message: `"${item.url}" is already on the playlist` + }) + } else { + buffer[item.url] = true + } - const channel_id = id.generate(item.name, country) - const found = blocklist.find( - blocked => - item.tvg.id.toLowerCase() === blocked.channel.toLowerCase() || - channel_id.toLowerCase() === blocked.channel.toLowerCase() - ) - if (found) { - fileLog.push({ - type: 'error', - line: item.line, - message: `"${found.name}" is on the blocklist due to claims of copyright holders (${found.ref})` - }) + const channel_id = id.generate(item.name, country) + const found = blocklist.find( + blocked => + item.tvg.id.toLowerCase() === blocked.channel.toLowerCase() || + channel_id.toLowerCase() === blocked.channel.toLowerCase() + ) + if (found) { + fileLog.push({ + type: 'error', + line: item.line, + message: `"${found.name}" is on the blocklist due to claims of copyright holders (${found.ref})` + }) + } } + } catch (err) { + fileLog.push({ + type: 'error', + line: 0, + message: err.message.toLowerCase() + }) } if (fileLog.length) {