aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/formatter
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/formatter')
-rw-r--r--server/models/video/formatter/video-format-utils.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts
index 5dc2c2f1b..ba49e41ae 100644
--- a/server/models/video/formatter/video-format-utils.ts
+++ b/server/models/video/formatter/video-format-utils.ts
@@ -42,6 +42,7 @@ export type VideoFormattingJSONOptions = {
42 waitTranscoding?: boolean 42 waitTranscoding?: boolean
43 scheduledUpdate?: boolean 43 scheduledUpdate?: boolean
44 blacklistInfo?: boolean 44 blacklistInfo?: boolean
45 files?: boolean
45 blockedOwner?: boolean 46 blockedOwner?: boolean
46 } 47 }
47} 48}
@@ -55,6 +56,7 @@ function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSaniti
55 waitTranscoding: !!(query.include & VideoInclude.NOT_PUBLISHED_STATE), 56 waitTranscoding: !!(query.include & VideoInclude.NOT_PUBLISHED_STATE),
56 scheduledUpdate: !!(query.include & VideoInclude.NOT_PUBLISHED_STATE), 57 scheduledUpdate: !!(query.include & VideoInclude.NOT_PUBLISHED_STATE),
57 blacklistInfo: !!(query.include & VideoInclude.BLACKLISTED), 58 blacklistInfo: !!(query.include & VideoInclude.BLACKLISTED),
59 files: !!(query.include & VideoInclude.FILES),
58 blockedOwner: !!(query.include & VideoInclude.BLOCKED_OWNER) 60 blockedOwner: !!(query.include & VideoInclude.BLOCKED_OWNER)
59 } 61 }
60 } 62 }
@@ -150,22 +152,26 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm
150 videoObject.blockedServer = !!(server?.isBlocked()) 152 videoObject.blockedServer = !!(server?.isBlocked())
151 } 153 }
152 154
155 if (add?.files === true) {
156 videoObject.streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists)
157 videoObject.files = videoFilesModelToFormattedJSON(video, video.VideoFiles)
158 }
159
153 return videoObject 160 return videoObject
154} 161}
155 162
156function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails { 163function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails {
157 const formattedJson = video.toFormattedJSON({ 164 const videoJSON = video.toFormattedJSON({
158 additionalAttributes: { 165 additionalAttributes: {
159 scheduledUpdate: true, 166 scheduledUpdate: true,
160 blacklistInfo: true 167 blacklistInfo: true,
168 files: true
161 } 169 }
162 }) 170 }) as Video & Required<Pick<Video, 'files' | 'streamingPlaylists'>>
163 171
164 const tags = video.Tags ? video.Tags.map(t => t.name) : [] 172 const tags = video.Tags ? video.Tags.map(t => t.name) : []
165 173
166 const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists) 174 const detailsJSON = {
167
168 const detailsJson = {
169 support: video.support, 175 support: video.support,
170 descriptionPath: video.getDescriptionAPIPath(), 176 descriptionPath: video.getDescriptionAPIPath(),
171 channel: video.VideoChannel.toFormattedJSON(), 177 channel: video.VideoChannel.toFormattedJSON(),
@@ -179,20 +185,14 @@ function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): Vid
179 label: getStateLabel(video.state) 185 label: getStateLabel(video.state)
180 }, 186 },
181 187
182 trackerUrls: video.getTrackerUrls(), 188 trackerUrls: video.getTrackerUrls()
183
184 files: [],
185 streamingPlaylists
186 } 189 }
187 190
188 // Format and sort video files 191 return Object.assign(videoJSON, detailsJSON)
189 detailsJson.files = videoFilesModelToFormattedJSON(video, video.VideoFiles)
190
191 return Object.assign(formattedJson, detailsJson)
192} 192}
193 193
194function streamingPlaylistsModelToFormattedJSON ( 194function streamingPlaylistsModelToFormattedJSON (
195 video: MVideoFormattableDetails, 195 video: MVideoFormattable,
196 playlists: MStreamingPlaylistRedundanciesOpt[] 196 playlists: MStreamingPlaylistRedundanciesOpt[]
197): VideoStreamingPlaylist[] { 197): VideoStreamingPlaylist[] {
198 if (isArray(playlists) === false) return [] 198 if (isArray(playlists) === false) return []
@@ -223,7 +223,7 @@ function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) {
223} 223}
224 224
225function videoFilesModelToFormattedJSON ( 225function videoFilesModelToFormattedJSON (
226 video: MVideoFormattableDetails, 226 video: MVideoFormattable,
227 videoFiles: MVideoFileRedundanciesOpt[], 227 videoFiles: MVideoFileRedundanciesOpt[],
228 includeMagnet = true 228 includeMagnet = true
229): VideoFile[] { 229): VideoFile[] {