Added support tvg-url attribute

This commit is contained in:
freearhey 2019-11-02 17:30:12 +03:00
parent 8307d12b0b
commit 9d647e8c68
2 changed files with 15 additions and 13 deletions

View File

@ -55,6 +55,7 @@ function parseIndex() {
const channel = helper.createChannel(item) const channel = helper.createChannel(item)
channel.countryCode = countryCode channel.countryCode = countryCode
channel.countryName = countryName channel.countryName = countryName
channel.epg = playlist.header.attrs['x-tvg-url'] || ''
// all // all
list.all.push(channel) list.all.push(channel)

View File

@ -51,18 +51,6 @@ helper.parsePlaylist = function(filename) {
return new Playlist(result) return new Playlist(result)
} }
helper.createChannel = function(data) {
return new Channel({
id: data.tvg.id,
name: data.tvg.name,
language: data.tvg.language,
logo: data.tvg.logo,
group: data.group.title,
url: data.url,
title: data.name
})
}
helper.loadEPG = async function(url) { helper.loadEPG = async function(url) {
const content = await getEPGFile(url) const content = await getEPGFile(url)
const result = epgParser.parse(content) const result = epgParser.parse(content)
@ -202,6 +190,18 @@ helper.generateTable = function(data, options) {
return output return output
} }
helper.createChannel = function(data) {
return new Channel({
id: data.tvg.id,
name: data.tvg.name,
language: data.tvg.language,
logo: data.tvg.logo,
group: data.group.title,
url: data.url,
title: data.name
})
}
class Playlist { class Playlist {
constructor(data) { constructor(data) {
this.header = data.header this.header = data.header
@ -257,7 +257,8 @@ class Channel {
toString() { toString() {
const country = this.countryCode.toUpperCase() const country = this.countryCode.toUpperCase()
const info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-language="${this.language}" tvg-logo="${this.logo}" tvg-country="${country}" group-title="${this.group}",${this.title}` const epg = (this.id && this.epg) ? this.epg : ''
const info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-language="${this.language}" tvg-logo="${this.logo}" tvg-country="${country}" tvg-url="${epg}" group-title="${this.group}",${this.title}`
return '#EXTINF:' + info + '\n' + this.url + '\n' return '#EXTINF:' + info + '\n' + this.url + '\n'
} }