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 : ''