mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update validate.js
This commit is contained in:
parent
68e08a9aa1
commit
c09d4c29e7
1 changed files with 17 additions and 11 deletions
|
@ -8,8 +8,8 @@ async function main() {
|
||||||
await api.channels.load()
|
await api.channels.load()
|
||||||
|
|
||||||
const stats = {
|
const stats = {
|
||||||
channels: 0,
|
files: 0,
|
||||||
files: 0
|
errors: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!program.args.length) {
|
if (!program.args.length) {
|
||||||
|
@ -21,26 +21,32 @@ async function main() {
|
||||||
|
|
||||||
const { site, channels } = await parser.parseChannels(filepath)
|
const { site, channels } = await parser.parseChannels(filepath)
|
||||||
|
|
||||||
const output = []
|
const buffer = {}
|
||||||
|
const errors = []
|
||||||
for (const channel of channels) {
|
for (const channel of channels) {
|
||||||
|
if (!buffer[channel.xmltv_id]) {
|
||||||
|
buffer[channel.xmltv_id] = channel
|
||||||
|
} else {
|
||||||
|
errors.push({ type: 'duplicate', ...channel })
|
||||||
|
stats.errors++
|
||||||
|
}
|
||||||
|
|
||||||
if (!api.channels.find({ id: channel.xmltv_id })) {
|
if (!api.channels.find({ id: channel.xmltv_id })) {
|
||||||
output.push(channel)
|
errors.push({ type: 'wrong_xmltv_id', ...channel })
|
||||||
stats.channels++
|
stats.errors++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.length) {
|
if (errors.length) {
|
||||||
logger.info(chalk.underline(filepath))
|
logger.info(chalk.underline(filepath))
|
||||||
console.table(output, ['lang', 'xmltv_id', 'site_id', 'name'])
|
console.table(errors, ['type', 'lang', 'xmltv_id', 'site_id', 'name'])
|
||||||
console.log()
|
console.log()
|
||||||
stats.files++
|
stats.files++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.channels > 0) {
|
if (stats.errors > 0) {
|
||||||
logger.error(
|
logger.error(chalk.red(`${stats.errors} error(s) in ${stats.files} file(s)`))
|
||||||
chalk.red(`${stats.channels} channel(s) in ${stats.files} file(s) have the wrong xmltv_id`)
|
|
||||||
)
|
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue