diff --git a/src/api.js b/src/api.js index e070552..8d17890 100644 --- a/src/api.js +++ b/src/api.js @@ -140,8 +140,8 @@ function api(db, xmltvInterval) { let channels = db['channels'].find() var data = "#EXTM3U\n" for (var i = 0; i < channels.length; i++) { - data += `#EXTINF:0 tvg-id="${channels[i].number}" tvg-name="${channels[i].name}" tvg-logo="${channels[i].icon}",${channels[i].number}\n` - data += `http://${process.env.HOST}:${process.env.PORT}/video?channel=${channels[i].number}\n` + data += `#EXTINF:0 tvg-id="${channels[i].number}" tvg-name="${channels[i].name}" tvg-logo="${channels[i].icon}",${channels[i].name}\n` + data += `http://${process.env.HOST}:${process.env.PORT}/video?channel=${channels[i].number}|User-Agent=ffmpeg\n` } res.send(data) }) diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 032af84..03cd1b8 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -9,6 +9,7 @@ class ffmpeg extends events.EventEmitter { } spawn(lineupItem) { let args = [ + '-headers', 'User-Agent: ffmpeg', '-threads', this.opts.threads, '-ss', lineupItem.start / 1000, '-t', lineupItem.duration / 1000, diff --git a/src/hdhr.js b/src/hdhr.js index 34f7935..9ee767e 100644 --- a/src/hdhr.js +++ b/src/hdhr.js @@ -48,7 +48,7 @@ function hdhr(db) { var lineup = [] var channels = db['channels'].find() for (let i = 0, l = channels.length; i < l; i++) - lineup.push({ GuideNumber: channels[i].number.toString(), GuideName: channels[i].name, URL: `http://${process.env.HOST}:${process.env.PORT}/video?channel=${channels[i].number}` }) + lineup.push({ GuideNumber: channels[i].number.toString(), GuideName: channels[i].name, URL: `http://${process.env.HOST}:${process.env.PORT}/video?channel=${channels[i].number}|User-Agent=ffmpeg` }) res.send(JSON.stringify(lineup)) }) diff --git a/src/helperFuncs.js b/src/helperFuncs.js index fed6c96..f0694fe 100644 --- a/src/helperFuncs.js +++ b/src/helperFuncs.js @@ -47,9 +47,7 @@ function getCurrentProgramAndTimeElapsed(date, channel) { } function createProgramStreamTimeline(obj) { - let timeElapsed = obj.timeElapsed - console.log(timeElapsed) let activeProgram = obj.program let lineup = [] let programStartTimes = [0, activeProgram.actualDuration * .25, activeProgram.actualDuration * .50, activeProgram.actualDuration * .75, activeProgram.actualDuration] @@ -86,7 +84,7 @@ function createProgramStreamTimeline(obj) { lineup.push({ type: 'program', file: activeProgram.file, - start: progTimeElapsed + timeElapsed, + start: progTimeElapsed + timeElapsed, // add the duration of already played program chunks to the timeElapsed duration: (programStartTimes[i + 1] - programStartTimes[i]) - timeElapsed }) } else if (foundFirstVideo) { @@ -102,7 +100,7 @@ function createProgramStreamTimeline(obj) { } } else { timeElapsed -= (programStartTimes[i + 1] - programStartTimes[i]) - progTimeElapsed += (programStartTimes[i + 1] - programStartTimes[i]) + progTimeElapsed += (programStartTimes[i + 1] - programStartTimes[i]) // add the duration of already played program chunks together } } } diff --git a/src/plex.js b/src/plex.js index 23fe40b..925d0ed 100644 --- a/src/plex.js +++ b/src/plex.js @@ -34,7 +34,8 @@ class Plex { login: username, password: password } - } + }, + jar: false } request(req, (err, res, body) => { if (err || res.statusCode !== 201) @@ -50,7 +51,8 @@ class Plex { var req = { method: 'get', url: `${this.URL}${path}`, - headers: this._headers + headers: this._headers, + jar: false } Object.assign(req, optionalHeaders) req.headers['X-Plex-Token'] = this._token @@ -71,7 +73,8 @@ class Plex { method: 'put', url: `${this.URL}${path}`, headers: this._headers, - qs: query + qs: query, + jar: false } Object.assign(req, optionalHeaders) req.headers['X-Plex-Token'] = this._token @@ -92,7 +95,8 @@ class Plex { method: 'post', url: `${this.URL}${path}`, headers: this._headers, - qs: query + qs: query, + jar: false } Object.assign(req, optionalHeaders) req.headers['X-Plex-Token'] = this._token