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) {