mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-28 13:46:20 +02:00
parent
a89a24e48e
commit
2cc6e56bd1
@ -146,7 +146,7 @@ class Stream extends EventEmitter {
|
|||||||
|
|
||||||
async generatePlaylist() {
|
async generatePlaylist() {
|
||||||
await fs.ensureDir(this.streamPath)
|
await fs.ensureDir(this.streamPath)
|
||||||
await hlsPlaylistGenerator(this.playlistPath, 'output', this.totalDuration, this.segmentLength, this.hlsSegmentType, this.userToken)
|
await hlsPlaylistGenerator(this.playlistPath, 'output', this.totalDuration, this.segmentLength, this.hlsSegmentType)
|
||||||
return this.clientPlaylistUri
|
return this.clientPlaylistUri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const fs = require('../../libs/fsExtra')
|
const fs = require('../../libs/fsExtra')
|
||||||
|
|
||||||
function getPlaylistStr(segmentName, duration, segmentLength, hlsSegmentType, token) {
|
function getPlaylistStr(segmentName, duration, segmentLength, hlsSegmentType) {
|
||||||
var ext = hlsSegmentType === 'fmp4' ? 'm4s' : 'ts'
|
var ext = hlsSegmentType === 'fmp4' ? 'm4s' : 'ts'
|
||||||
|
|
||||||
var lines = [
|
var lines = [
|
||||||
@ -18,18 +18,18 @@ function getPlaylistStr(segmentName, duration, segmentLength, hlsSegmentType, to
|
|||||||
var lastSegment = duration - (numSegments * segmentLength)
|
var lastSegment = duration - (numSegments * segmentLength)
|
||||||
for (let i = 0; i < numSegments; i++) {
|
for (let i = 0; i < numSegments; i++) {
|
||||||
lines.push(`#EXTINF:6,`)
|
lines.push(`#EXTINF:6,`)
|
||||||
lines.push(`${segmentName}-${i}.${ext}?token=${token}`)
|
lines.push(`${segmentName}-${i}.${ext}`)
|
||||||
}
|
}
|
||||||
if (lastSegment > 0) {
|
if (lastSegment > 0) {
|
||||||
lines.push(`#EXTINF:${lastSegment},`)
|
lines.push(`#EXTINF:${lastSegment},`)
|
||||||
lines.push(`${segmentName}-${numSegments}.${ext}?token=${token}`)
|
lines.push(`${segmentName}-${numSegments}.${ext}`)
|
||||||
}
|
}
|
||||||
lines.push('#EXT-X-ENDLIST')
|
lines.push('#EXT-X-ENDLIST')
|
||||||
return lines.join('\n')
|
return lines.join('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePlaylist(outputPath, segmentName, duration, segmentLength, hlsSegmentType, token) {
|
function generatePlaylist(outputPath, segmentName, duration, segmentLength, hlsSegmentType) {
|
||||||
var playlistStr = getPlaylistStr(segmentName, duration, segmentLength, hlsSegmentType, token)
|
var playlistStr = getPlaylistStr(segmentName, duration, segmentLength, hlsSegmentType)
|
||||||
return fs.writeFile(outputPath, playlistStr)
|
return fs.writeFile(outputPath, playlistStr)
|
||||||
}
|
}
|
||||||
module.exports = generatePlaylist
|
module.exports = generatePlaylist
|
Loading…
Reference in New Issue
Block a user