Update Channel.js

This commit is contained in:
Aleksandr Statciuk 2021-08-02 21:48:07 +03:00
parent 3d761612d9
commit 6e189ad5bc
1 changed files with 10 additions and 2 deletions

View File

@ -12,10 +12,11 @@ module.exports = class Channel {
this.http = data.http this.http = data.http
this.url = data.url this.url = data.url
this.logo = data.tvg.logo this.logo = data.tvg.logo
this.category = data.group.title this.group = data.group
this.name = this.parseName(data.name) this.name = this.parseName(data.name)
this.status = this.parseStatus(data.name) this.status = this.parseStatus(data.name)
this.resolution = this.parseResolution(data.name) this.resolution = this.parseResolution(data.name)
this.category = this.parseCategory(data.group.title)
this.countries = this.parseCountries(data.tvg.country) this.countries = this.parseCountries(data.tvg.country)
this.languages = this.parseLanguages(data.tvg.language) this.languages = this.parseLanguages(data.tvg.language)
} }
@ -43,6 +44,13 @@ module.exports = class Channel {
return { width: null, height } return { width: null, height }
} }
parseCategory(string) {
const category = categories.find(c => c.id === string.toLowerCase())
if (!category) return ''
return category.name
}
parseCountries(string) { parseCountries(string) {
const list = string.split(';') const list = string.split(';')
return list return list
@ -92,7 +100,7 @@ module.exports = class Channel {
getInfo() { getInfo() {
let info = `-1 tvg-id="${this.tvg.id}" tvg-name="${this.tvg.name}" tvg-country="${this.tvg.country}" tvg-language="${this.tvg.language}" tvg-logo="${this.logo}"` let info = `-1 tvg-id="${this.tvg.id}" tvg-name="${this.tvg.name}" tvg-country="${this.tvg.country}" tvg-language="${this.tvg.language}" tvg-logo="${this.logo}"`
info += ` group-title="${this.category}",${this.name}` info += ` group-title="${this.group.title}",${this.name}`
if (this.resolution.height) { if (this.resolution.height) {
info += ` (${this.resolution.height}p)` info += ` (${this.resolution.height}p)`