aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index b8e383502..a8ea67c39 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1592,22 +1592,21 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1592 } 1592 }
1593 1593
1594 getQualityFileBy<T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) { 1594 getQualityFileBy<T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) {
1595 // We first transcode to WebTorrent format, so try this array first 1595 const files = this.getAllFiles()
1596 if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) { 1596 const file = fun(files, file => file.resolution)
1597 const file = fun(this.VideoFiles, file => file.resolution) 1597 if (!file) return undefined
1598 1598
1599 if (file.videoId) {
1599 return Object.assign(file, { Video: this }) 1600 return Object.assign(file, { Video: this })
1600 } 1601 }
1601 1602
1602 // No webtorrent files, try with streaming playlist files 1603 if (file.videoStreamingPlaylistId) {
1603 if (Array.isArray(this.VideoStreamingPlaylists) && this.VideoStreamingPlaylists.length !== 0) {
1604 const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this }) 1604 const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this })
1605 1605
1606 const file = fun(streamingPlaylistWithVideo.VideoFiles, file => file.resolution)
1607 return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo }) 1606 return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo })
1608 } 1607 }
1609 1608
1610 return undefined 1609 throw new Error('File is not associated to a video of a playlist')
1611 } 1610 }
1612 1611
1613 getMaxQualityFile<T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo { 1612 getMaxQualityFile<T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo {