diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video.ts | 33 |
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 | } |