aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/formatter
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-12 16:09:02 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-10-24 14:48:24 +0200
commit3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (patch)
treee7f1d12ef5dae1e1142c3a8d0b681c1dbbb0de10 /server/models/video/formatter
parent38a3ccc7f8ad0ea94362b58c732af7c387ab46be (diff)
downloadPeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.gz
PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.zst
PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.zip
Put private videos under a specific subdirectory
Diffstat (limited to 'server/models/video/formatter')
-rw-r--r--server/models/video/formatter/video-format-utils.ts22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts
index e1b0eb610..76745f4b5 100644
--- a/server/models/video/formatter/video-format-utils.ts
+++ b/server/models/video/formatter/video-format-utils.ts
@@ -34,6 +34,7 @@ import {
34import { 34import {
35 MServer, 35 MServer,
36 MStreamingPlaylistRedundanciesOpt, 36 MStreamingPlaylistRedundanciesOpt,
37 MUserId,
37 MVideo, 38 MVideo,
38 MVideoAP, 39 MVideoAP,
39 MVideoFile, 40 MVideoFile,
@@ -245,8 +246,12 @@ function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) {
245function videoFilesModelToFormattedJSON ( 246function videoFilesModelToFormattedJSON (
246 video: MVideoFormattable, 247 video: MVideoFormattable,
247 videoFiles: MVideoFileRedundanciesOpt[], 248 videoFiles: MVideoFileRedundanciesOpt[],
248 includeMagnet = true 249 options: {
250 includeMagnet?: boolean // default true
251 } = {}
249): VideoFile[] { 252): VideoFile[] {
253 const { includeMagnet = true } = options
254
250 const trackerUrls = includeMagnet 255 const trackerUrls = includeMagnet
251 ? video.getTrackerUrls() 256 ? video.getTrackerUrls()
252 : [] 257 : []
@@ -281,11 +286,14 @@ function videoFilesModelToFormattedJSON (
281 }) 286 })
282} 287}
283 288
284function addVideoFilesInAPAcc ( 289function addVideoFilesInAPAcc (options: {
285 acc: ActivityUrlObject[] | ActivityTagObject[], 290 acc: ActivityUrlObject[] | ActivityTagObject[]
286 video: MVideo, 291 video: MVideo
287 files: MVideoFile[] 292 files: MVideoFile[]
288) { 293 user?: MUserId
294}) {
295 const { acc, video, files } = options
296
289 const trackerUrls = video.getTrackerUrls() 297 const trackerUrls = video.getTrackerUrls()
290 298
291 const sortedFiles = (files || []) 299 const sortedFiles = (files || [])
@@ -370,7 +378,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
370 } 378 }
371 ] 379 ]
372 380
373 addVideoFilesInAPAcc(url, video, video.VideoFiles || []) 381 addVideoFilesInAPAcc({ acc: url, video, files: video.VideoFiles || [] })
374 382
375 for (const playlist of (video.VideoStreamingPlaylists || [])) { 383 for (const playlist of (video.VideoStreamingPlaylists || [])) {
376 const tag = playlist.p2pMediaLoaderInfohashes 384 const tag = playlist.p2pMediaLoaderInfohashes
@@ -382,7 +390,7 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
382 href: playlist.getSha256SegmentsUrl(video) 390 href: playlist.getSha256SegmentsUrl(video)
383 }) 391 })
384 392
385 addVideoFilesInAPAcc(tag, video, playlist.VideoFiles || []) 393 addVideoFilesInAPAcc({ acc: tag, video, files: playlist.VideoFiles || [] })
386 394
387 url.push({ 395 url.push({
388 type: 'Link', 396 type: 'Link',