aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 73e0d2345..af6fae0b6 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { maxBy } from 'lodash' 2import { maxBy, minBy } from 'lodash'
3import { join } from 'path' 3import { join } from 'path'
4import { 4import {
5 CountOptions, 5 CountOptions,
@@ -1802,9 +1802,9 @@ export class VideoModel extends Model<VideoModel> {
1802 this.VideoChannel.Account.isBlocked() 1802 this.VideoChannel.Account.isBlocked()
1803 } 1803 }
1804 1804
1805 getMaxQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo { 1805 getQualityFileBy <T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) {
1806 if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) { 1806 if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) {
1807 const file = maxBy(this.VideoFiles, file => file.resolution) 1807 const file = fun(this.VideoFiles, file => file.resolution)
1808 1808
1809 return Object.assign(file, { Video: this }) 1809 return Object.assign(file, { Video: this })
1810 } 1810 }
@@ -1813,13 +1813,21 @@ export class VideoModel extends Model<VideoModel> {
1813 if (Array.isArray(this.VideoStreamingPlaylists) && this.VideoStreamingPlaylists.length !== 0) { 1813 if (Array.isArray(this.VideoStreamingPlaylists) && this.VideoStreamingPlaylists.length !== 0) {
1814 const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this }) 1814 const streamingPlaylistWithVideo = Object.assign(this.VideoStreamingPlaylists[0], { Video: this })
1815 1815
1816 const file = maxBy(streamingPlaylistWithVideo.VideoFiles, file => file.resolution) 1816 const file = fun(streamingPlaylistWithVideo.VideoFiles, file => file.resolution)
1817 return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo }) 1817 return Object.assign(file, { VideoStreamingPlaylist: streamingPlaylistWithVideo })
1818 } 1818 }
1819 1819
1820 return undefined 1820 return undefined
1821 } 1821 }
1822 1822
1823 getMaxQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo {
1824 return this.getQualityFileBy(maxBy)
1825 }
1826
1827 getMinQualityFile <T extends MVideoWithFile> (this: T): MVideoFileVideo | MVideoFileStreamingPlaylistVideo {
1828 return this.getQualityFileBy(minBy)
1829 }
1830
1823 getWebTorrentFile <T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo { 1831 getWebTorrentFile <T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo {
1824 if (Array.isArray(this.VideoFiles) === false) return undefined 1832 if (Array.isArray(this.VideoFiles) === false) return undefined
1825 1833