mirror of
https://github.com/iptv-org/database.git
synced 2025-05-09 19:20:01 -04:00
Update validate.ts
This commit is contained in:
parent
c96d052d91
commit
a897c4c284
1 changed files with 26 additions and 6 deletions
|
@ -79,15 +79,13 @@ async function main() {
|
||||||
for (const [i, row] of rowsCopy.entries()) {
|
for (const [i, row] of rowsCopy.entries()) {
|
||||||
fileErrors = fileErrors.concat(validateChannelId(row, i))
|
fileErrors = fileErrors.concat(validateChannelId(row, i))
|
||||||
fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i))
|
fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i))
|
||||||
|
fileErrors = fileErrors.concat(validateReplacedBy(row, i))
|
||||||
fileErrors = fileErrors.concat(
|
fileErrors = fileErrors.concat(
|
||||||
checkValue(i, row, 'id', 'subdivision', buffer.get('subdivisions'))
|
checkValue(i, row, 'id', 'subdivision', buffer.get('subdivisions'))
|
||||||
)
|
)
|
||||||
fileErrors = fileErrors.concat(
|
fileErrors = fileErrors.concat(
|
||||||
checkValue(i, row, 'id', 'categories', buffer.get('categories'))
|
checkValue(i, row, 'id', 'categories', buffer.get('categories'))
|
||||||
)
|
)
|
||||||
fileErrors = fileErrors.concat(
|
|
||||||
checkValue(i, row, 'id', 'replaced_by', buffer.get('channels'))
|
|
||||||
)
|
|
||||||
fileErrors = fileErrors.concat(
|
fileErrors = fileErrors.concat(
|
||||||
checkValue(i, row, 'id', 'languages', buffer.get('languages'))
|
checkValue(i, row, 'id', 'languages', buffer.get('languages'))
|
||||||
)
|
)
|
||||||
|
@ -102,9 +100,7 @@ async function main() {
|
||||||
for (const [i, row] of rowsCopy.entries()) {
|
for (const [i, row] of rowsCopy.entries()) {
|
||||||
fileErrors = fileErrors.concat(validateChannel(row.channel, i))
|
fileErrors = fileErrors.concat(validateChannel(row.channel, i))
|
||||||
fileErrors = fileErrors.concat(validateTimezones(row, i))
|
fileErrors = fileErrors.concat(validateTimezones(row, i))
|
||||||
fileErrors = fileErrors.concat(
|
fileErrors = fileErrors.concat(validateReplacedBy(row, i))
|
||||||
checkValue(i, row, 'id', 'replaced_by', buffer.get('channels'))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'blocklist':
|
case 'blocklist':
|
||||||
|
@ -198,6 +194,30 @@ function checkValue(
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateReplacedBy(row: { [key: string]: string }, i: number) {
|
||||||
|
const errors = new Collection()
|
||||||
|
|
||||||
|
if (!row.replaced_by) return errors
|
||||||
|
|
||||||
|
const channels = buffer.get('channels')
|
||||||
|
const feeds = buffer.get('feeds')
|
||||||
|
const [channelId, feedId] = row.replaced_by.split('@')
|
||||||
|
|
||||||
|
if (channels.missing(channelId)) {
|
||||||
|
errors.push({
|
||||||
|
line: i + 2,
|
||||||
|
message: `"${row.id}" has an invalid replaced_by "${row.replaced_by}"`
|
||||||
|
})
|
||||||
|
} else if (feedId && feeds.missing(channelId + feedId)) {
|
||||||
|
errors.push({
|
||||||
|
line: i + 2,
|
||||||
|
message: `"${row.id}" has an invalid replaced_by "${row.replaced_by}"`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors
|
||||||
|
}
|
||||||
|
|
||||||
function validateChannel(channelId: string, i: number) {
|
function validateChannel(channelId: string, i: number) {
|
||||||
const errors = new Collection()
|
const errors = new Collection()
|
||||||
const channels = buffer.get('channels')
|
const channels = buffer.get('channels')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue