Update parser.js

Generates the missing tvg-id based on the channel name
This commit is contained in:
freearhey 2021-03-06 21:17:26 +03:00
parent 24e2268e96
commit 1c4defd9ae
1 changed files with 12 additions and 4 deletions

View File

@ -67,10 +67,10 @@ class Channel {
constructor({ data, header, sourceUrl }) {
this.parseData(data)
this.filename = utils.getBasename(sourceUrl)
if (!this.countries.length) {
const filename = utils.getBasename(sourceUrl)
const countryName = utils.code2name(filename)
this.countries = countryName ? [{ code: filename.toLowerCase(), name: countryName }] : []
const countryName = utils.code2name(this.filename)
this.countries = countryName ? [{ code: this.filename, name: countryName }] : []
this.tvg.country = this.countries.map(c => c.code.toUpperCase()).join(';')
}
@ -173,7 +173,15 @@ class Channel {
}
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() {