mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 02:20:03 -04:00
Update validate.js
This commit is contained in:
parent
7fe8a3da7b
commit
c18bf41b38
1 changed files with 38 additions and 30 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue