mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-14 02:50:04 -04:00
Update parser.js
Generates the missing tvg-id based on the channel name
This commit is contained in:
parent
24e2268e96
commit
1c4defd9ae
1 changed files with 12 additions and 4 deletions
|
@ -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() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue