mirror of
https://github.com/iptv-org/database.git
synced 2024-11-22 02:44:10 -05:00
Update validate.js
This commit is contained in:
parent
6087a6c06a
commit
34d05d513f
1 changed files with 25 additions and 0 deletions
|
@ -53,6 +53,25 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileErrors = fileErrors.concat(findDuplicatesById(data))
|
fileErrors = fileErrors.concat(findDuplicatesById(data))
|
||||||
|
|
||||||
|
let categories = await csv.fromFile('data/categories.csv').catch(err => {
|
||||||
|
logger.error(chalk.red(`\nError: ${err.message}`))
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
categories = categories.map(c => c.id)
|
||||||
|
|
||||||
|
data.forEach((row, i) => {
|
||||||
|
if (
|
||||||
|
categories.length &&
|
||||||
|
row.categories.length &&
|
||||||
|
intersection(categories, row.categories).length !== row.categories.length
|
||||||
|
) {
|
||||||
|
fileErrors.push({
|
||||||
|
line: i + 2,
|
||||||
|
message: `"${row.id}" has the wrong categories "${row.categories.join(';')}"`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if (filename === 'blocklist') {
|
} else if (filename === 'blocklist') {
|
||||||
let channels = await csv.fromFile('data/channels.csv').catch(err => {
|
let channels = await csv.fromFile('data/channels.csv').catch(err => {
|
||||||
logger.error(chalk.red(`\nError: ${err.message}`))
|
logger.error(chalk.red(`\nError: ${err.message}`))
|
||||||
|
@ -118,3 +137,9 @@ function findDuplicatesById(data) {
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function intersection(array1, array2) {
|
||||||
|
return array1.filter(function (n) {
|
||||||
|
return array2.indexOf(n) !== -1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue