FFMPEG User-Agent headers added to stream. M3U channel title fixed. M3U and HDHR channel urls include User-Agent

This commit is contained in:
Dan Ferguson 2020-04-26 13:20:52 -04:00
parent 00ba6a73c7
commit da4ff9fe1f
5 changed files with 14 additions and 11 deletions

View File

@ -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)
})

View File

@ -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,

View File

@ -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))
})

View File

@ -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
}
}
}

View File

@ -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