Update filter.js

This commit is contained in:
Aleksandr Statciuk 2021-07-13 19:10:31 +03:00
parent aed62aaa50
commit 6f912ee5bf
1 changed files with 9 additions and 5 deletions

View File

@ -2,8 +2,6 @@ const parser = require('./parser')
const utils = require('./utils')
const blacklist = require('./blacklist.json')
let globalBuffer = []
async function main() {
const playlists = parseIndex()
for (const playlist of playlists) {
@ -28,9 +26,15 @@ async function loadPlaylist(url) {
async function removeBlacklisted(playlist) {
console.info(` Looking for blacklisted channels...`)
const list = blacklist.map(i => i.toLowerCase())
playlist.channels = playlist.channels.filter(i => {
return !list.includes(i.name.toLowerCase())
playlist.channels = playlist.channels.filter(channel => {
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
)
})
})
return playlist