You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iptv/scripts/filter.js

41 lines
996 B
JavaScript

3 years ago
const blacklist = require('./blacklist.json')
4 years ago
const parser = require('./parser')
const utils = require('./utils')
3 years ago
const log = require('./log')
4 years ago
async function main() {
3 years ago
log.start()
log.print(`Parsing 'index.m3u'...`)
const playlists = parser.parseIndex()
4 years ago
for (const playlist of playlists) {
3 years ago
log.print(`\nProcessing '${playlist.url}'...`)
await parser.parsePlaylist(playlist.url).then(removeBlacklisted).then(utils.savePlaylist)
4 years ago
}
3 years ago
log.finish()
4 years ago
}
async function removeBlacklisted(playlist) {
3 years ago
const channels = playlist.channels.filter(channel => {
4 years ago
return !blacklist.find(i => {
const channelName = channel.name.toLowerCase()
return (
(i.name.toLowerCase() === channelName ||
i.aliases.map(i => i.toLowerCase()).includes(channelName)) &&
i.country === channel.filename
)
})
4 years ago
})
3 years ago
if (playlist.channels.length !== channels.length) {
log.print(`updated`)
4 years ago
}
3 years ago
playlist.channels = channels
4 years ago
3 years ago
return playlist
4 years ago
}
main()