Update filter.js

This commit is contained in:
Aleksandr Statciuk 2021-08-22 17:50:24 +03:00
parent a9ebb223e6
commit f1d5acdc0b
1 changed files with 2 additions and 8 deletions

View File

@ -21,11 +21,9 @@ async function main() {
function removeBlacklisted(playlist) {
const channels = playlist.channels.filter(channel => {
const channelName = normalizeName(channel.name)
return !blacklist.find(item => {
const hasSameName =
normalizeName(item.name) === channelName ||
item.aliases.map(alias => normalizeName(alias)).includes(channelName)
const regexp = new RegExp(item.regex, 'i')
const hasSameName = regexp.test(channel.name)
const fromSameCountry = playlist.country.code === item.country
return hasSameName && fromSameCountry
@ -41,8 +39,4 @@ function removeBlacklisted(playlist) {
return playlist
}
function normalizeName(str) {
return str.replace(/[^a-zA-Z0-9 ]/gi, '').toLowerCase()
}
main()