Added support for multiple languages per channel

This commit is contained in:
freearhey 2020-04-12 18:33:06 +03:00
parent 3dca4085e4
commit 56fae45453
2 changed files with 10 additions and 13 deletions

View File

@ -75,11 +75,13 @@ function parseIndex() {
countries[countryCode].push(channel) countries[countryCode].push(channel)
// language // language
const languageCode = helper.getISO6391Code(channel.language) || 'undefined' for (let language of channel.language.split(';')) {
const languageCode = helper.getISO6391Code(language) || 'undefined'
if (!languages[languageCode]) { if (!languages[languageCode]) {
languages[languageCode] = [] languages[languageCode] = []
} }
languages[languageCode].push(channel) languages[languageCode].push(channel)
}
// category // category
const categoryCode = channel.group.toLowerCase() || 'other' const categoryCode = channel.group.toLowerCase() || 'other'

View File

@ -224,7 +224,10 @@ class Channel {
constructor(data) { constructor(data) {
this.id = data.tvg.id this.id = data.tvg.id
this.name = data.tvg.name 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.logo = data.tvg.logo
this.group = this._filterGroup(data.group.title) this.group = this._filterGroup(data.group.title)
this.url = data.url this.url = data.url
@ -280,14 +283,6 @@ class Channel {
return groupTitle return groupTitle
} }
_filterLanguage(languageName) {
if (helper.getISO6391Code(languageName)) {
return languageName
}
return ''
}
toString() { toString() {
const country = this.countryCode.toUpperCase() const country = this.countryCode.toUpperCase()
const epg = this.id && this.epg ? this.epg : '' const epg = this.id && this.epg ? this.epg : ''