Update format.js

Deletes blacklisted channels
This commit is contained in:
freearhey 2021-03-01 01:43:45 +03:00
parent b691aeecd7
commit 73ada87393
1 changed files with 12 additions and 0 deletions

View File

@ -1,4 +1,5 @@
const { program } = require('commander')
const blacklist = require('./blacklist')
const parser = require('./parser')
const utils = require('./utils')
const axios = require('axios')
@ -35,6 +36,7 @@ async function main() {
await loadPlaylist(playlist.url)
.then(addToBuffer)
.then(sortChannels)
.then(filterChannels)
.then(removeDuplicates)
.then(detectResolution)
.then(updateFromEPG)
@ -83,6 +85,16 @@ async function sortChannels(playlist) {
return playlist
}
async function filterChannels(playlist) {
console.info(` Filtering channels...`)
const list = blacklist.map(i => i.toLowerCase())
playlist.channels = playlist.channels.filter(i => {
return !list.includes(i.name.toLowerCase())
})
return playlist
}
async function removeDuplicates(playlist) {
console.info(` Looking for duplicates...`)
let buffer = {}