diff options
Diffstat (limited to 'server/models/video/video-format-utils.ts')
-rw-r--r-- | server/models/video/video-format-utils.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 284539def..2987aa780 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' | 1 | import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos' |
2 | import { VideoModel } from './video' | 2 | import { VideoModel } from './video' |
3 | import { VideoFileModel } from './video-file' | ||
4 | import { | 3 | import { |
5 | ActivityPlaylistInfohashesObject, | 4 | ActivityPlaylistInfohashesObject, |
6 | ActivityPlaylistSegmentHashesObject, | 5 | ActivityPlaylistSegmentHashesObject, |
@@ -17,7 +16,9 @@ import { | |||
17 | } from '../../lib/activitypub' | 16 | } from '../../lib/activitypub' |
18 | import { isArray } from '../../helpers/custom-validators/misc' | 17 | import { isArray } from '../../helpers/custom-validators/misc' |
19 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | 18 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' |
20 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 19 | import { MStreamingPlaylistRedundanciesOpt, MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models' |
20 | import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist' | ||
21 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' | ||
21 | 22 | ||
22 | export type VideoFormattingJSONOptions = { | 23 | export type VideoFormattingJSONOptions = { |
23 | completeDescription?: boolean | 24 | completeDescription?: boolean |
@@ -28,7 +29,7 @@ export type VideoFormattingJSONOptions = { | |||
28 | blacklistInfo?: boolean | 29 | blacklistInfo?: boolean |
29 | } | 30 | } |
30 | } | 31 | } |
31 | function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video { | 32 | function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFormattingJSONOptions): Video { |
32 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined | 33 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined |
33 | 34 | ||
34 | const videoObject: Video = { | 35 | const videoObject: Video = { |
@@ -102,7 +103,7 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting | |||
102 | return videoObject | 103 | return videoObject |
103 | } | 104 | } |
104 | 105 | ||
105 | function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { | 106 | function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails { |
106 | const formattedJson = video.toFormattedJSON({ | 107 | const formattedJson = video.toFormattedJSON({ |
107 | additionalAttributes: { | 108 | additionalAttributes: { |
108 | scheduledUpdate: true, | 109 | scheduledUpdate: true, |
@@ -114,7 +115,7 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { | |||
114 | 115 | ||
115 | const tags = video.Tags ? video.Tags.map(t => t.name) : [] | 116 | const tags = video.Tags ? video.Tags.map(t => t.name) : [] |
116 | 117 | ||
117 | const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists) | 118 | const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video.VideoStreamingPlaylists) |
118 | 119 | ||
119 | const detailsJson = { | 120 | const detailsJson = { |
120 | support: video.support, | 121 | support: video.support, |
@@ -142,7 +143,7 @@ function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails { | |||
142 | return Object.assign(formattedJson, detailsJson) | 143 | return Object.assign(formattedJson, detailsJson) |
143 | } | 144 | } |
144 | 145 | ||
145 | function streamingPlaylistsModelToFormattedJSON (video: VideoModel, playlists: VideoStreamingPlaylistModel[]): VideoStreamingPlaylist[] { | 146 | function streamingPlaylistsModelToFormattedJSON (playlists: MStreamingPlaylistRedundanciesOpt[]): VideoStreamingPlaylist[] { |
146 | if (isArray(playlists) === false) return [] | 147 | if (isArray(playlists) === false) return [] |
147 | 148 | ||
148 | return playlists | 149 | return playlists |
@@ -161,7 +162,7 @@ function streamingPlaylistsModelToFormattedJSON (video: VideoModel, playlists: V | |||
161 | }) | 162 | }) |
162 | } | 163 | } |
163 | 164 | ||
164 | function videoFilesModelToFormattedJSON (video: VideoModel, videoFiles: VideoFileModel[]): VideoFile[] { | 165 | function videoFilesModelToFormattedJSON (video: MVideo, videoFiles: MVideoFileRedundanciesOpt[]): VideoFile[] { |
165 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() | 166 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() |
166 | 167 | ||
167 | return videoFiles | 168 | return videoFiles |
@@ -189,7 +190,7 @@ function videoFilesModelToFormattedJSON (video: VideoModel, videoFiles: VideoFil | |||
189 | }) | 190 | }) |
190 | } | 191 | } |
191 | 192 | ||
192 | function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { | 193 | function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject { |
193 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() | 194 | const { baseUrlHttp, baseUrlWs } = video.getBaseUrls() |
194 | if (!video.Tags) video.Tags = [] | 195 | if (!video.Tags) video.Tags = [] |
195 | 196 | ||