Table,
UpdatedAt
} from 'sequelize-typescript'
-import { getHLSPublicFileUrl } from '@server/lib/object-storage'
+import { CONFIG } from '@server/initializers/config'
+import { getHLSPrivateFileUrl, getHLSPublicFileUrl } from '@server/lib/object-storage'
import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '@server/lib/paths'
+import { isVideoInPrivateDirectory } from '@server/lib/video-privacy'
import { VideoFileModel } from '@server/models/video/video-file'
import { MStreamingPlaylist, MStreamingPlaylistFilesVideo, MVideo } from '@server/types/models'
import { sha1 } from '@shared/extra-utils'
this.p2pMediaLoaderInfohashes = VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(masterPlaylistUrl, files)
}
+ // ---------------------------------------------------------------------------
+
getMasterPlaylistUrl (video: MVideo) {
if (video.isOwned()) {
if (this.storage === VideoStorage.OBJECT_STORAGE) {
- return getHLSPublicFileUrl(this.playlistUrl)
+ return this.getMasterPlaylistObjectStorageUrl(video)
}
- return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid)
+ return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video)
}
return this.playlistUrl
}
+ private getMasterPlaylistObjectStorageUrl (video: MVideo) {
+ if (video.hasPrivateStaticPath() && CONFIG.OBJECT_STORAGE.PROXY.PROXIFY_PRIVATE_FILES === true) {
+ return getHLSPrivateFileUrl(video, this.playlistFilename)
+ }
+
+ return getHLSPublicFileUrl(this.playlistUrl)
+ }
+
+ // ---------------------------------------------------------------------------
+
getSha256SegmentsUrl (video: MVideo) {
if (video.isOwned()) {
if (this.storage === VideoStorage.OBJECT_STORAGE) {
- return getHLSPublicFileUrl(this.segmentsSha256Url)
+ return this.getSha256SegmentsObjectStorageUrl(video)
}
- return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid)
+ return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video)
}
return this.segmentsSha256Url
}
+ private getSha256SegmentsObjectStorageUrl (video: MVideo) {
+ if (video.hasPrivateStaticPath() && CONFIG.OBJECT_STORAGE.PROXY.PROXIFY_PRIVATE_FILES === true) {
+ return getHLSPrivateFileUrl(video, this.segmentsSha256Filename)
+ }
+
+ return getHLSPublicFileUrl(this.segmentsSha256Url)
+ }
+
+ // ---------------------------------------------------------------------------
+
getStringType () {
if (this.type === VideoStreamingPlaylistType.HLS) return 'hls'
return Object.assign(this, { Video: video })
}
- private getMasterPlaylistStaticPath (videoUUID: string) {
- return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename)
+ private getMasterPlaylistStaticPath (video: MVideo) {
+ if (isVideoInPrivateDirectory(video.privacy)) {
+ return join(STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, video.uuid, this.playlistFilename)
+ }
+
+ return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, video.uuid, this.playlistFilename)
}
- private getSha256SegmentsStaticPath (videoUUID: string) {
- return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.segmentsSha256Filename)
+ private getSha256SegmentsStaticPath (video: MVideo) {
+ if (isVideoInPrivateDirectory(video.privacy)) {
+ return join(STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, video.uuid, this.segmentsSha256Filename)
+ }
+
+ return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, video.uuid, this.segmentsSha256Filename)
}
}