From a41bda5f5e2c3fc008855c009be30fede1903e0c Mon Sep 17 00:00:00 2001 From: freearhey Date: Wed, 27 Jan 2021 18:19:40 +0300 Subject: [PATCH] Update helper.js --- scripts/helper.js | 75 +++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/scripts/helper.js b/scripts/helper.js index 553706530..5c7fadb2c 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -11,6 +11,38 @@ const iso6393 = require('iso-639-3') let helper = {} +helper.supportedCategories = { + auto: 'Auto', + business: 'Business', + classic: 'Classic', + comedy: 'Comedy', + documentary: 'Documentary', + education: 'Education', + entertainment: 'Entertainment', + family: 'Family', + fashion: 'Fashion', + food: 'Food', + general: 'General', + health: 'Health', + history: 'History', + hobby: 'Hobby', + kids: 'Kids', + legislative: 'Legislative', + lifestyle: 'Lifestyle', + local: 'Local', + movies: 'Movies', + music: 'Music', + news: 'News', + quiz: 'Quiz', + religious: 'Religious', + 'sci-fi': 'Sci-Fi', + shop: 'Shop', + sport: 'Sport', + travel: 'Travel', + weather: 'Weather', + xxx: 'XXX' +} + helper.code2flag = function (code) { switch (code) { case 'uk': @@ -205,48 +237,7 @@ helper.filterPlaylists = function (arr, include = '', exclude = '') { } helper.filterGroup = function (groupTitle) { - if (!groupTitle) return '' - - const supportedCategories = [ - 'Auto', - 'Business', - 'Classic', - 'Comedy', - 'Documentary', - 'Education', - 'Entertainment', - 'Family', - 'Fashion', - 'Food', - 'General', - 'Health', - 'History', - 'Hobby', - 'Kids', - 'Legislative', - 'Lifestyle', - 'Local', - 'Movies', - 'Music', - 'News', - 'Quiz', - 'Religious', - 'Sci-Fi', - 'Shop', - 'Sport', - 'Travel', - 'Weather', - 'XXX' - ] - const groupIndex = supportedCategories.map(g => g.toLowerCase()).indexOf(groupTitle.toLowerCase()) - - if (groupIndex === -1) { - groupTitle = '' - } else { - groupTitle = supportedCategories[groupIndex] - } - - return groupTitle + return this.supportedCategories[groupTitle.toLowerCase()] || '' } helper.sleep = function (ms) {