From bc570de9ce3c5b930e0a9365ecfcfbdbe5ec9adc Mon Sep 17 00:00:00 2001 From: freearhey Date: Sat, 25 Apr 2020 19:58:32 +0300 Subject: [PATCH] Moved filterPlaylist() back to helper.js Need for test.js --- scripts/format.js | 18 +----------------- scripts/helper.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/format.js b/scripts/format.js index 3fc6d612e2..ea804fb08e 100644 --- a/scripts/format.js +++ b/scripts/format.js @@ -65,7 +65,7 @@ async function main() { function parseIndex() { const playlist = helper.parsePlaylist('index.m3u') - playlist.items = filterPlaylists(playlist.items, config.country, config.exclude) + playlist.items = helper.filterPlaylists(playlist.items, config.country, config.exclude) console.log(`Found ${playlist.items.length + 1} playlist(s)`) @@ -172,22 +172,6 @@ function updatePlaylist(filepath, playlist) { console.log(`Playlist '${filepath}' has been updated`) } -function filterPlaylists(arr, include = '', exclude = '') { - if (include) { - const included = include.split(',').map((filename) => `channels/${filename}.m3u`) - - return arr.filter((i) => included.indexOf(i.url) > -1) - } - - if (exclude) { - const excluded = exclude.split(',').map((filename) => `channels/${filename}.m3u`) - - return arr.filter((i) => excluded.indexOf(i.url) === -1) - } - - return arr -} - function filterUnsorted() { const urls = items.map((i) => i.url) const unsortedPlaylist = parsePlaylist('channels/unsorted.m3u') diff --git a/scripts/helper.js b/scripts/helper.js index 016a32345e..bf5cbd4980 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -188,6 +188,22 @@ helper.parseMessage = function (err, u) { return line.replace(`${u}: `, '') } +helper.filterPlaylists = function (arr, include = '', exclude = '') { + if (include) { + const included = include.split(',').map((filename) => `channels/${filename}.m3u`) + + return arr.filter((i) => included.indexOf(i.url) > -1) + } + + if (exclude) { + const excluded = exclude.split(',').map((filename) => `channels/${filename}.m3u`) + + return arr.filter((i) => excluded.indexOf(i.url) === -1) + } + + return arr +} + class Playlist { constructor(data) { this.header = data.header