Created filter script

This commit is contained in:
freearhey 2019-07-22 17:57:53 +03:00
parent a396642ce6
commit 9fec039d23
2 changed files with 56 additions and 1 deletions

54
helpers/filter.js Normal file
View File

@ -0,0 +1,54 @@
const util = require('./util')
const debug = false
const blacklist = [
'80.80.160.168', // repeats on a loop
]
let stats = {
total: 0,
removed: 0
}
function init() {
let countries = util.parsePlaylist('index.m3u')
if(debug) {
countries = countries.slice(0, 2)
}
let channels = []
for(let country of countries) {
const playlist = util.parsePlaylist(country.file)
for(let item of playlist) {
const url = new URL(item.file)
const host = url.hostname
if(blacklist.indexOf(host) === -1) {
channels.push(item)
} else {
stats.removed += 1
}
}
util.createFile(country.file, '#EXTM3U\n')
channels.forEach(item => {
const data = '#EXTINF:' + item.title + '\n' + item.file + '\n'
util.writeToFile(country.file, data)
})
stats.total += channels.length
channels = []
}
}
init()
console.log(`Total: ${stats.total}. Removed: ${stats.removed}`)

View File

@ -10,7 +10,8 @@
"scripts": {
"test": "node test/index.js",
"generate": "node helpers/generate.js",
"format": "node helpers/format.js"
"format": "node helpers/format.js",
"filter": "node helpers/filter.js"
},
"repository": {
"type": "git",