aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-06 10:40:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-06 11:03:09 +0200
commitaa8b6df4a51c82eb91e6fd71a090b2128098af6b (patch)
treeb2d6292ceb34ad71a1ce9b671f0d87923f6c7c21 /server/models
parent127d96b969891a73d76e257581e5fd81cd867480 (diff)
downloadPeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.tar.gz
PeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.tar.zst
PeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.zip
Client: handle multiple file resolutions
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts33
1 files changed, 20 insertions, 13 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index b4a2b0c95..c376d769e 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -477,19 +477,26 @@ toFormattedJSON = function (this: VideoInstance) {
477 files: [] 477 files: []
478 } 478 }
479 479
480 this.VideoFiles.forEach(videoFile => { 480 // Format and sort video files
481 let resolutionLabel = VIDEO_FILE_RESOLUTIONS[videoFile.resolution] 481 json.files = this.VideoFiles
482 if (!resolutionLabel) resolutionLabel = 'Unknown' 482 .map(videoFile => {
483 483 let resolutionLabel = VIDEO_FILE_RESOLUTIONS[videoFile.resolution]
484 const videoFileJson = { 484 if (!resolutionLabel) resolutionLabel = 'Unknown'
485 resolution: videoFile.resolution, 485
486 resolutionLabel, 486 const videoFileJson = {
487 magnetUri: this.generateMagnetUri(videoFile), 487 resolution: videoFile.resolution,
488 size: videoFile.size 488 resolutionLabel,
489 } 489 magnetUri: this.generateMagnetUri(videoFile),
490 490 size: videoFile.size
491 json.files.push(videoFileJson) 491 }
492 }) 492
493 return videoFileJson
494 })
495 .sort((a, b) => {
496 if (a.resolution < b.resolution) return 1
497 if (a.resolution === b.resolution) return 0
498 return -1
499 })
493 500
494 return json 501 return json
495} 502}