Update utils.js

This commit is contained in:
Aleksandr Statciuk 2021-09-08 20:03:01 +03:00
parent 0deaf545d0
commit 1f6e9de4ba

View File

@ -74,17 +74,17 @@ utils.removeProtocol = function (string) {
return string.replace(/(^\w+:|^)\/\//, '')
}
utils.filterPlaylists = function (arr, include = '', exclude = '') {
utils.filterFiles = function (arr, include = '', exclude = '') {
if (include) {
const included = include.split(',').map(filename => `channels/${filename}.m3u`)
return arr.filter(i => included.indexOf(i.url) > -1)
return arr.filter(filename => included.includes(filename))
}
if (exclude) {
const excluded = exclude.split(',').map(filename => `channels/${filename}.m3u`)
return arr.filter(i => excluded.indexOf(i.url) === -1)
return arr.filter(filename => !excluded.includes(filename))
}
return arr