mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Fix HLS private static path
This commit is contained in:
parent
473cd4f7ef
commit
94deeb0a8f
3 changed files with 47 additions and 18 deletions
|
@ -5,7 +5,9 @@ import {
|
|||
ensureCanAccessPrivateVideoHLSFiles,
|
||||
ensureCanAccessVideoPrivateWebVideoFiles,
|
||||
handleStaticError,
|
||||
optionalAuthenticate
|
||||
optionalAuthenticate,
|
||||
privateHLSFileValidator,
|
||||
privateM3U8PlaylistValidator
|
||||
} from '@server/middlewares/index.js'
|
||||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
|
@ -55,17 +57,20 @@ const privateHLSStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUIRE_AU
|
|||
: []
|
||||
|
||||
staticRouter.use(
|
||||
STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + ':videoUUID/:playlistNameWithoutExtension.m3u8',
|
||||
STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + ':videoUUID/:playlistNameWithoutExtension([a-z0-9-]+).m3u8',
|
||||
privateM3U8PlaylistValidator,
|
||||
...privateHLSStaticMiddlewares,
|
||||
asyncMiddleware(servePrivateM3U8)
|
||||
)
|
||||
|
||||
staticRouter.use(
|
||||
STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS,
|
||||
STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + ':videoUUID/:filename',
|
||||
privateHLSFileValidator,
|
||||
...privateHLSStaticMiddlewares,
|
||||
express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }),
|
||||
handleStaticError
|
||||
servePrivateHLSFile
|
||||
)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
staticRouter.use(
|
||||
STATIC_PATHS.STREAMING_PLAYLISTS.HLS,
|
||||
express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, { fallthrough: false }),
|
||||
|
@ -80,6 +85,12 @@ export {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function servePrivateHLSFile (req: express.Request, res: express.Response) {
|
||||
const path = join(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, req.params.videoUUID, req.params.filename)
|
||||
|
||||
return res.sendFile(path)
|
||||
}
|
||||
|
||||
async function servePrivateM3U8 (req: express.Request, res: express.Response) {
|
||||
const path = join(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, req.params.videoUUID, req.params.playlistNameWithoutExtension + '.m3u8')
|
||||
const filename = req.params.playlistNameWithoutExtension + '.m3u8'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue