2021-08-01 18:50:33 +02:00
|
|
|
const blacklist = require('./helpers/blacklist.json')
|
|
|
|
const parser = require('./helpers/parser')
|
|
|
|
const log = require('./helpers/log')
|
2021-07-13 17:14:49 +02:00
|
|
|
|
|
|
|
async function main() {
|
2021-08-01 06:55:18 +02:00
|
|
|
log.start()
|
|
|
|
|
|
|
|
log.print(`Parsing 'index.m3u'...`)
|
|
|
|
const playlists = parser.parseIndex()
|
2021-07-13 17:14:49 +02:00
|
|
|
for (const playlist of playlists) {
|
2021-08-01 06:55:18 +02:00
|
|
|
log.print(`\nProcessing '${playlist.url}'...`)
|
2021-08-02 20:18:59 +02:00
|
|
|
await parser
|
|
|
|
.parsePlaylist(playlist.url)
|
|
|
|
.then(removeBlacklisted)
|
|
|
|
.then(p => p.save())
|
2021-07-13 17:14:49 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 18:50:33 +02:00
|
|
|
log.print('\n')
|
2021-08-01 06:55:18 +02:00
|
|
|
log.finish()
|
2021-07-13 17:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function removeBlacklisted(playlist) {
|
2021-08-01 06:55:18 +02:00
|
|
|
const channels = playlist.channels.filter(channel => {
|
2021-08-02 20:18:59 +02:00
|
|
|
return !blacklist.find(item => {
|
|
|
|
const hasSameName =
|
|
|
|
item.name.toLowerCase() === channel.name.toLowerCase() ||
|
|
|
|
item.aliases.map(alias => alias.toLowerCase()).includes(channel.name.toLowerCase())
|
|
|
|
const fromSameCountry = channel.countries.find(c => c.code === item.country)
|
|
|
|
|
|
|
|
return hasSameName && fromSameCountry
|
2021-07-13 18:10:31 +02:00
|
|
|
})
|
2021-07-13 17:14:49 +02:00
|
|
|
})
|
|
|
|
|
2021-08-01 06:55:18 +02:00
|
|
|
if (playlist.channels.length !== channels.length) {
|
|
|
|
log.print(`updated`)
|
2021-08-01 19:46:26 +02:00
|
|
|
playlist.channels = channels
|
2021-08-02 20:18:59 +02:00
|
|
|
playlist.updated = true
|
2021-07-13 17:14:49 +02:00
|
|
|
}
|
|
|
|
|
2021-08-01 06:55:18 +02:00
|
|
|
return playlist
|
2021-07-13 17:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|