|
|
|
@ -298,60 +298,9 @@ helper.code2country = function (code) {
|
|
|
|
|
return { code, name: intlDisplayNames.of(code.toUpperCase()) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Playlist {
|
|
|
|
|
constructor(data) {
|
|
|
|
|
this.header = data.header
|
|
|
|
|
this.items = data.items
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getHeader() {
|
|
|
|
|
let parts = ['#EXTM3U']
|
|
|
|
|
for (let key in this.header.attrs) {
|
|
|
|
|
let value = this.header.attrs[key]
|
|
|
|
|
if (value) {
|
|
|
|
|
parts.push(`${key}="${value}"`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `${parts.join(' ')}\n`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Channel {
|
|
|
|
|
constructor(data, parent) {
|
|
|
|
|
this.parseData(data, parent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseData(data, parent) {
|
|
|
|
|
this.source = helper.getBasename(parent.url)
|
|
|
|
|
this.logo = data.tvg.logo
|
|
|
|
|
this.category = helper.filterGroup(data.group.title)
|
|
|
|
|
this.url = data.url
|
|
|
|
|
this.name = this.parseName(data.name)
|
|
|
|
|
this.status = this.parseStatus(data.name)
|
|
|
|
|
this.http = data.http
|
|
|
|
|
this.tvg = data.tvg
|
|
|
|
|
this.tvg.url = parent.header.attrs['x-tvg-url'] || ''
|
|
|
|
|
this.countries = this.parseCountries(data.tvg.country)
|
|
|
|
|
this.resolution = this.parseResolution(data.name)
|
|
|
|
|
this.language = this.parseLanguage(data.tvg.language)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get languageName() {
|
|
|
|
|
return this.language[0] ? this.language[0].name : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get countryName() {
|
|
|
|
|
return this.countries[0] ? this.countries[0].name : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get countryCode() {
|
|
|
|
|
return this.countries[0] ? this.countries[0].code : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseCountries(value) {
|
|
|
|
|
helper.parseCountries = function (value, source) {
|
|
|
|
|
if (!value) {
|
|
|
|
|
const country = helper.code2country(this.source)
|
|
|
|
|
const country = helper.code2country(source)
|
|
|
|
|
return country ? [country] : []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -361,7 +310,7 @@ class Channel {
|
|
|
|
|
.map(helper.code2country)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseName(title) {
|
|
|
|
|
helper.parseName = function (title) {
|
|
|
|
|
return title
|
|
|
|
|
.trim()
|
|
|
|
|
.split(' ')
|
|
|
|
@ -372,14 +321,14 @@ class Channel {
|
|
|
|
|
.join(' ')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseStatus(title) {
|
|
|
|
|
helper.parseStatus = function (title) {
|
|
|
|
|
const regex = /\[(.*)\]/i
|
|
|
|
|
const match = title.match(regex)
|
|
|
|
|
|
|
|
|
|
return match ? match[1] : null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseResolution(title) {
|
|
|
|
|
helper.parseResolution = function (title) {
|
|
|
|
|
const regex = /\((\d+)P\)/i
|
|
|
|
|
const match = title.match(regex)
|
|
|
|
|
|
|
|
|
@ -389,7 +338,7 @@ class Channel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseLanguage(lang) {
|
|
|
|
|
helper.parseLanguages = function (lang) {
|
|
|
|
|
return lang
|
|
|
|
|
.split(';')
|
|
|
|
|
.map(name => {
|
|
|
|
@ -404,12 +353,59 @@ class Channel {
|
|
|
|
|
.filter(l => l)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Playlist {
|
|
|
|
|
constructor(data) {
|
|
|
|
|
this.header = data.header
|
|
|
|
|
this.items = data.items
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getHeader() {
|
|
|
|
|
let parts = ['#EXTM3U']
|
|
|
|
|
for (let key in this.header.attrs) {
|
|
|
|
|
let value = this.header.attrs[key]
|
|
|
|
|
if (value) {
|
|
|
|
|
parts.push(`${key}="${value}"`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `${parts.join(' ')}\n`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Channel {
|
|
|
|
|
constructor(data, parent) {
|
|
|
|
|
this.parseData(data, parent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parseData(data, parent) {
|
|
|
|
|
this.source = helper.getBasename(parent.url)
|
|
|
|
|
this.logo = data.tvg.logo
|
|
|
|
|
this.category = helper.filterGroup(data.group.title)
|
|
|
|
|
this.url = data.url
|
|
|
|
|
this.name = helper.parseName(data.name)
|
|
|
|
|
this.status = helper.parseStatus(data.name)
|
|
|
|
|
this.http = data.http
|
|
|
|
|
this.tvg = data.tvg
|
|
|
|
|
this.tvg.url = parent.header.attrs['x-tvg-url'] || ''
|
|
|
|
|
this.countries = helper.parseCountries(data.tvg.country, this.source)
|
|
|
|
|
this.resolution = helper.parseResolution(data.name)
|
|
|
|
|
this.languages = helper.parseLanguages(data.tvg.language)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get languageAttribute() {
|
|
|
|
|
return this.getLanguageAttribute()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get countryAttribute() {
|
|
|
|
|
return this.getCountryAttribute()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCountryAttribute() {
|
|
|
|
|
return this.countries.map(c => c.code.toUpperCase()).join(';')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLanguageAttribute() {
|
|
|
|
|
return this.language.map(l => l.name).join(';')
|
|
|
|
|
return this.languages.map(l => l.name).join(';')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toString() {
|
|
|
|
@ -457,7 +453,7 @@ class Channel {
|
|
|
|
|
logo: this.logo || null,
|
|
|
|
|
url: this.url,
|
|
|
|
|
category: this.category || null,
|
|
|
|
|
language: this.language,
|
|
|
|
|
languages: this.languages,
|
|
|
|
|
countries: this.countries,
|
|
|
|
|
tvg: {
|
|
|
|
|
id: this.tvg.id || null,
|
|
|
|
|