Update filter.js

This commit is contained in:
Aleksandr Statciuk 2021-07-13 19:10:31 +03:00
parent aed62aaa50
commit 6f912ee5bf

View File

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