Added language name filter

This commit is contained in:
freearhey 2019-11-01 17:15:33 +03:00
parent 55d3689e1b
commit 624c103d04
1 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ const axios = require('axios')
const zlib = require("zlib")
const epgParser = require('epg-parser')
const urlParser = require('url')
const ISO6391 = require('iso-639-1')
const supportedCategories = [ 'Auto','Business', 'Classic','Comedy','Documentary','Education','Entertainment', 'Family','Fashion','Food', 'General', 'Health', 'History', 'Hobby', 'Kids', 'Legislative','Lifestyle','Local', 'Movies', 'Music', 'News', 'Quiz', 'Religious','Sci-Fi', 'Shop', 'Sport', 'Travel', 'Weather', 'XXX' ]
@ -39,7 +40,7 @@ class Channel {
constructor(data) {
this.id = data.tvg.id
this.name = data.tvg.name
this.language = data.tvg.language
this.language = this._filterLanguage(data.tvg.language)
this.logo = data.tvg.logo
this.group = this._filterGroup(data.group.title)
this.url = data.url
@ -60,6 +61,14 @@ class Channel {
return groupTitle
}
_filterLanguage(languageName) {
if(ISO6391.getCode(languageName) !== '') {
return languageName
}
return ''
}
toString() {
const info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-language="${this.language}" tvg-logo="${this.logo}" group-title="${this.group}",${this.title}`