From 80cbff843c4a518b84fc1362e3b481d62da12d42 Mon Sep 17 00:00:00 2001 From: freearhey Date: Sat, 11 Apr 2020 18:56:41 +0300 Subject: [PATCH] Added support for #EXTVLCOPT:http-referrer and #EXTVLCOPT:http-user-agent stream options --- scripts/helper.js | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/scripts/helper.js b/scripts/helper.js index f4f335c63..c84fc7f5f 100644 --- a/scripts/helper.js +++ b/scripts/helper.js @@ -175,15 +175,7 @@ helper.generateTable = function (data, options) { } 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 - }) + return new Channel(data) } helper.writeToLog = function (country, msg, url) { @@ -230,13 +222,15 @@ class Playlist { class Channel { constructor(data) { - this.id = data.id - this.name = data.name - this.language = this._filterLanguage(data.language) - this.logo = data.logo - this.group = this._filterGroup(data.group) + this.id = data.tvg.id + this.name = data.tvg.name + this.language = this._filterLanguage(data.tvg.language) + this.logo = data.tvg.logo + this.group = this._filterGroup(data.group.title) this.url = data.url - this.title = data.title + this.title = data.name.trim() + this.userAgent = data.http['user-agent'] + this.referrer = data.http['referrer'] } _filterGroup(groupTitle) { @@ -297,13 +291,30 @@ class Channel { toString() { const country = this.countryCode.toUpperCase() 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}` + + let 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}` + + if (this.referrer) { + info += `\n#EXTVLCOPT:http-referrer=${this.referrer}` + } + + if (this.userAgent) { + info += `\n#EXTVLCOPT:http-user-agent=${this.userAgent}` + } return '#EXTINF:' + info + '\n' + this.url + '\n' } toShortString() { - const info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-language="${this.language}" tvg-logo="${this.logo}" group-title="${this.group}",${this.title}` + let info = `-1 tvg-id="${this.id}" tvg-name="${this.name}" tvg-language="${this.language}" tvg-logo="${this.logo}" group-title="${this.group}",${this.title}` + + if (this.referrer) { + info += `\n#EXTVLCOPT:http-referrer=${this.referrer}` + } + + if (this.userAgent) { + info += `\n#EXTVLCOPT:http-user-agent=${this.userAgent}` + } return '#EXTINF:' + info + '\n' + this.url + '\n' }