From 17ada75249c09e0f3fd9aa281f632b2436dca153 Mon Sep 17 00:00:00 2001 From: freearhey Date: Sun, 7 Jul 2019 04:08:20 +0300 Subject: [PATCH] Added check for supported groups name --- helpers/formatter.js | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/helpers/formatter.js b/helpers/formatter.js index 481d1345b..71b9929c5 100644 --- a/helpers/formatter.js +++ b/helpers/formatter.js @@ -5,11 +5,44 @@ const path = require('path') const urlParser = require('url') let total = 0 +const supportedGroups = [ + 'Auto', + 'Business', + 'CCTV', + 'Classic', + 'Comedy', + 'Documentary', + 'Education', + 'Entertainment', + 'Family', + 'Fashion', + 'Food', + 'General', + 'Health', + 'History', + 'Hobby', + 'Kids', + 'Legislative', + 'Lifestyle', + 'Local', + 'Movies', + 'Music', + 'News', + 'Quiz', + 'Radio', + 'Religious', + 'Sci-Fi', + 'Shop', + 'Sport', + 'Travel', + 'Weather', + 'XXX' +] function init() { let countries = loadPlaylist('index.m3u') - // countries = countries.slice(0, 10) + // countries = countries.slice(0, 4) let channels = [] @@ -99,8 +132,16 @@ function parseTvgLogo(item) { function parseGroupTitle(item) { let info = getInfo(item) let matches = info.match(/group\-title\=\"(.*?)\"/i) + let groupTitle = (matches && matches.length > 1) ? matches[1] : '' + let groupIndex = supportedGroups.map(g => g.toLowerCase()).indexOf(groupTitle.toLowerCase()) - return (matches && matches.length > 1) ? matches[1] : '' + if(groupIndex === -1) { + groupTitle = '' + } else { + groupTitle = supportedGroups[groupIndex] + } + + return groupTitle } function byTitle(a, b) {