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
1.0 KiB
JavaScript

3 years ago
const blacklist = require('./helpers/blacklist.json')
const parser = require('./helpers/parser')
const utils = require('./helpers/utils')
const log = require('./helpers/log')
3 years ago
async function main() {
3 years ago
log.start()
log.print(`Parsing 'index.m3u'...`)
const playlists = parser.parseIndex()
3 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)
3 years ago
}
3 years ago
log.print('\n')
3 years ago
log.finish()
3 years ago
}
async function removeBlacklisted(playlist) {
3 years ago
const channels = playlist.channels.filter(channel => {
3 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
)
})
3 years ago
})
3 years ago
if (playlist.channels.length !== channels.length) {
log.print(`updated`)
3 years ago
playlist.channels = channels
3 years ago
}
3 years ago
return playlist
3 years ago
}
main()