aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-streaming-playlist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-streaming-playlist.ts')
-rw-r--r--server/models/video/video-streaming-playlist.ts28
1 files changed, 25 insertions, 3 deletions
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index b919046ed..1318a4dae 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -15,7 +15,7 @@ import {
15 Table, 15 Table,
16 UpdatedAt 16 UpdatedAt
17} from 'sequelize-typescript' 17} from 'sequelize-typescript'
18import { getHLSPublicFileUrl } from '@server/lib/object-storage' 18import { getHLSPrivateFileUrl, getHLSPublicFileUrl } from '@server/lib/object-storage'
19import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '@server/lib/paths' 19import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '@server/lib/paths'
20import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' 20import { isVideoInPrivateDirectory } from '@server/lib/video-privacy'
21import { VideoFileModel } from '@server/models/video/video-file' 21import { VideoFileModel } from '@server/models/video/video-file'
@@ -245,10 +245,12 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
245 this.p2pMediaLoaderInfohashes = VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(masterPlaylistUrl, files) 245 this.p2pMediaLoaderInfohashes = VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(masterPlaylistUrl, files)
246 } 246 }
247 247
248 // ---------------------------------------------------------------------------
249
248 getMasterPlaylistUrl (video: MVideo) { 250 getMasterPlaylistUrl (video: MVideo) {
249 if (video.isOwned()) { 251 if (video.isOwned()) {
250 if (this.storage === VideoStorage.OBJECT_STORAGE) { 252 if (this.storage === VideoStorage.OBJECT_STORAGE) {
251 return getHLSPublicFileUrl(this.playlistUrl) 253 return this.getMasterPlaylistObjectStorageUrl(video)
252 } 254 }
253 255
254 return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video) 256 return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video)
@@ -257,10 +259,20 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
257 return this.playlistUrl 259 return this.playlistUrl
258 } 260 }
259 261
262 private getMasterPlaylistObjectStorageUrl (video: MVideo) {
263 if (video.hasPrivateStaticPath()) {
264 return getHLSPrivateFileUrl(video, this.playlistFilename)
265 }
266
267 return getHLSPublicFileUrl(this.playlistUrl)
268 }
269
270 // ---------------------------------------------------------------------------
271
260 getSha256SegmentsUrl (video: MVideo) { 272 getSha256SegmentsUrl (video: MVideo) {
261 if (video.isOwned()) { 273 if (video.isOwned()) {
262 if (this.storage === VideoStorage.OBJECT_STORAGE) { 274 if (this.storage === VideoStorage.OBJECT_STORAGE) {
263 return getHLSPublicFileUrl(this.segmentsSha256Url) 275 return this.getSha256SegmentsObjectStorageUrl(video)
264 } 276 }
265 277
266 return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video) 278 return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video)
@@ -269,6 +281,16 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
269 return this.segmentsSha256Url 281 return this.segmentsSha256Url
270 } 282 }
271 283
284 private getSha256SegmentsObjectStorageUrl (video: MVideo) {
285 if (video.hasPrivateStaticPath()) {
286 return getHLSPrivateFileUrl(video, this.segmentsSha256Filename)
287 }
288
289 return getHLSPublicFileUrl(this.segmentsSha256Url)
290 }
291
292 // ---------------------------------------------------------------------------
293
272 getStringType () { 294 getStringType () {
273 if (this.type === VideoStreamingPlaylistType.HLS) return 'hls' 295 if (this.type === VideoStreamingPlaylistType.HLS) return 'hls'
274 296