Created channel.setLanguage() method

pull/1331/head
freearhey 5 years ago
parent ca06ca5f65
commit 595b4e044c

@ -278,20 +278,6 @@ class Channel {
} }
parseData(data) { 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.logo = data.tvg.logo
this.category = helper.filterGroup(data.group.title) this.category = helper.filterGroup(data.group.title)
this.url = data.url this.url = data.url
@ -302,6 +288,8 @@ class Channel {
code: null, code: null,
name: null name: null
} }
this.setLanguage(data.tvg.language)
} }
get ['language.name']() { get ['language.name']() {
@ -312,6 +300,21 @@ class Channel {
return this.country.name || null 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() { toString() {
const country = this.country.code ? this.country.code.toUpperCase() : '' const country = this.country.code ? this.country.code.toUpperCase() : ''
const tvgUrl = (this.tvg.id || this.tvg.name) && this.tvg.url ? this.tvg.url : '' const tvgUrl = (this.tvg.id || this.tvg.name) && this.tvg.url ? this.tvg.url : ''

Loading…
Cancel
Save