From 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Oct 2022 16:09:02 +0200 Subject: Put private videos under a specific subdirectory --- server/lib/paths.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'server/lib/paths.ts') diff --git a/server/lib/paths.ts b/server/lib/paths.ts index b29854700..470970f55 100644 --- a/server/lib/paths.ts +++ b/server/lib/paths.ts @@ -1,9 +1,10 @@ import { join } from 'path' import { CONFIG } from '@server/initializers/config' -import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY, VIDEO_LIVE } from '@server/initializers/constants' +import { DIRECTORIES, VIDEO_LIVE } from '@server/initializers/constants' import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' import { removeFragmentedMP4Ext } from '@shared/core-utils' import { buildUUID } from '@shared/extra-utils' +import { isVideoInPrivateDirectory } from './video-privacy' // ################## Video file name ################## @@ -17,20 +18,24 @@ function generateHLSVideoFilename (resolution: number) { // ################## Streaming playlist ################## -function getLiveDirectory (video: MVideoUUID) { +function getLiveDirectory (video: MVideo) { return getHLSDirectory(video) } -function getLiveReplayBaseDirectory (video: MVideoUUID) { +function getLiveReplayBaseDirectory (video: MVideo) { return join(getLiveDirectory(video), VIDEO_LIVE.REPLAY_DIRECTORY) } -function getHLSDirectory (video: MVideoUUID) { - return join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) +function getHLSDirectory (video: MVideo) { + if (isVideoInPrivateDirectory(video.privacy)) { + return join(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, video.uuid) + } + + return join(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, video.uuid) } function getHLSRedundancyDirectory (video: MVideoUUID) { - return join(HLS_REDUNDANCY_DIRECTORY, video.uuid) + return join(DIRECTORIES.HLS_REDUNDANCY, video.uuid) } function getHlsResolutionPlaylistFilename (videoFilename: string) { -- cgit v1.2.3