Update validate.js

pull/13278/head
freearhey 2 years ago
parent 7fe8a3da7b
commit c18bf41b38

@ -32,39 +32,47 @@ async function main() {
const buffer = {} const buffer = {}
const fileLog = [] const fileLog = []
const playlist = await parser.parsePlaylist(filepath) try {
for (const item of playlist.items) { const playlist = await parser.parsePlaylist(filepath)
if (item.tvg.id && !api.channels.find({ id: item.tvg.id })) { for (const item of playlist.items) {
fileLog.push({ if (item.tvg.id && !api.channels.find({ id: item.tvg.id })) {
type: 'warning', fileLog.push({
line: item.line, type: 'warning',
message: `"${item.tvg.id}" is not in the database` line: item.line,
}) message: `"${item.tvg.id}" is not in the database`
} })
}
if (item.url && buffer[item.url]) { if (item.url && buffer[item.url]) {
fileLog.push({ fileLog.push({
type: 'warning', type: 'warning',
line: item.line, line: item.line,
message: `"${item.url}" is already on the playlist` message: `"${item.url}" is already on the playlist`
}) })
} else { } else {
buffer[item.url] = true buffer[item.url] = true
} }
const channel_id = id.generate(item.name, country) const channel_id = id.generate(item.name, country)
const found = blocklist.find( const found = blocklist.find(
blocked => blocked =>
item.tvg.id.toLowerCase() === blocked.channel.toLowerCase() || item.tvg.id.toLowerCase() === blocked.channel.toLowerCase() ||
channel_id.toLowerCase() === blocked.channel.toLowerCase() channel_id.toLowerCase() === blocked.channel.toLowerCase()
) )
if (found) { if (found) {
fileLog.push({ fileLog.push({
type: 'error', type: 'error',
line: item.line, line: item.line,
message: `"${found.name}" is on the blocklist due to claims of copyright holders (${found.ref})` 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) { if (fileLog.length) {

Loading…
Cancel
Save