Added support of tvg-language attribute

This commit is contained in:
freearhey
2019-10-30 20:19:54 +03:00
parent 414295454d
commit f874effb9c
4 changed files with 29 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
const util = require('./util')
const escapeStringRegexp = require('escape-string-regexp')
const ISO6391 = require('iso-639-1')
const debug = false
const verbose = false
@@ -121,6 +122,15 @@ async function main() {
}
}
if(!channel.language && c.name.length && c.name[0].lang) {
let language = ISO6391.getName(c.name[0].lang)
channel.language = language
updated = true
if(verbose) {
console.log(`Added language '${language}' to '${channel.id}'`)
}
}
if(!channel.logo && c.icon.length) {
const icon = c.icon[0].split('|')[0]
channel.logo = icon

View File

@@ -39,6 +39,7 @@ class Channel {
constructor(data) {
this.id = data.tvg.id
this.name = data.tvg.name
this.language = data.tvg.language
this.logo = data.tvg.logo
this.group = this._getGroup(data.group.title)
this.url = data.url
@@ -60,7 +61,7 @@ class Channel {
}
toString() {
const info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-logo="${this.logo}" group-title="${this.group}",${this.title}`
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}`
return '#EXTINF:' + info + '\n' + this.url + '\n'
}