From 595b4e044c5c6834ba33fced8f7c425fcd12194d Mon Sep 17 00:00:00 2001 From: freearhey Date: Mon, 4 May 2020 16:31:58 +0300 Subject: [PATCH] Created channel.setLanguage() method --- scripts/helper.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/helper.js b/scripts/helper.js index 68437196f..30707ebe6 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -278,20 +278,6 @@ class Channel { } parseData(data) { - const language = data.tvg.language - .split(';') - .map(name => { - const code = name ? helper.getISO6391Code(name) : null - if (!code) return null - - return { - code, - name - } - }) - .filter(l => l) - - this.language = language this.logo = data.tvg.logo this.category = helper.filterGroup(data.group.title) this.url = data.url @@ -302,6 +288,8 @@ class Channel { code: null, name: null } + + this.setLanguage(data.tvg.language) } get ['language.name']() { @@ -312,6 +300,21 @@ class Channel { return this.country.name || null } + setLanguage(lang) { + this.language = lang + .split(';') + .map(name => { + const code = name ? helper.getISO6391Code(name) : null + if (!code) return null + + return { + code, + name + } + }) + .filter(l => l) + } + toString() { const country = this.country.code ? this.country.code.toUpperCase() : '' const tvgUrl = (this.tvg.id || this.tvg.name) && this.tvg.url ? this.tvg.url : ''