Update parser.js
Generates the missing tvg-id based on the channel name
This commit is contained in:
@ -67,10 +67,10 @@ class Channel {
|
|||||||
constructor({ data, header, sourceUrl }) {
|
constructor({ data, header, sourceUrl }) {
|
||||||
this.parseData(data)
|
this.parseData(data)
|
||||||
|
|
||||||
|
this.filename = utils.getBasename(sourceUrl)
|
||||||
if (!this.countries.length) {
|
if (!this.countries.length) {
|
||||||
const filename = utils.getBasename(sourceUrl)
|
const countryName = utils.code2name(this.filename)
|
||||||
const countryName = utils.code2name(filename)
|
this.countries = countryName ? [{ code: this.filename, name: countryName }] : []
|
||||||
this.countries = countryName ? [{ code: filename.toLowerCase(), name: countryName }] : []
|
|
||||||
this.tvg.country = this.countries.map(c => c.code.toUpperCase()).join(';')
|
this.tvg.country = this.countries.map(c => c.code.toUpperCase()).join(';')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,15 @@ class Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get tvgId() {
|
get tvgId() {
|
||||||
return this.tvg.id || ''
|
if (this.tvg.id) {
|
||||||
|
return this.tvg.id
|
||||||
|
} else if (this.filename !== 'unsorted') {
|
||||||
|
const id = utils.name2id(this.tvgName)
|
||||||
|
|
||||||
|
return id ? `${id}.${this.filename}` : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
get tvgName() {
|
get tvgName() {
|
||||||
|
Reference in New Issue
Block a user