From 56fae45453888519874816e3f8436edaafed3d88 Mon Sep 17 00:00:00 2001 From: freearhey Date: Sun, 12 Apr 2020 18:33:06 +0300 Subject: [PATCH] Added support for multiple languages per channel --- scripts/generate.js | 10 ++++++---- scripts/helper.js | 13 ++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/generate.js b/scripts/generate.js index f016822268..9fd5e11511 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -75,11 +75,13 @@ function parseIndex() { countries[countryCode].push(channel) // language - const languageCode = helper.getISO6391Code(channel.language) || 'undefined' - if (!languages[languageCode]) { - languages[languageCode] = [] + for (let language of channel.language.split(';')) { + const languageCode = helper.getISO6391Code(language) || 'undefined' + if (!languages[languageCode]) { + languages[languageCode] = [] + } + languages[languageCode].push(channel) } - languages[languageCode].push(channel) // category const categoryCode = channel.group.toLowerCase() || 'other' diff --git a/scripts/helper.js b/scripts/helper.js index c84fc7f5f1..255d4c7972 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -224,7 +224,10 @@ class Channel { constructor(data) { this.id = data.tvg.id this.name = data.tvg.name - this.language = this._filterLanguage(data.tvg.language) + this.language = data.tvg.language + .split(';') + .filter(l => !!helper.getISO6391Code(l)) + .join(';') this.logo = data.tvg.logo this.group = this._filterGroup(data.group.title) this.url = data.url @@ -280,14 +283,6 @@ class Channel { return groupTitle } - _filterLanguage(languageName) { - if (helper.getISO6391Code(languageName)) { - return languageName - } - - return '' - } - toString() { const country = this.countryCode.toUpperCase() const epg = this.id && this.epg ? this.epg : ''