diff options
Diffstat (limited to 'server/models/video/video-format-utils.ts')
-rw-r--r-- | server/models/video/video-format-utils.ts | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 67395e5c0..1fa66fd63 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -27,12 +27,13 @@ import { generateMagnetUri } from '@server/helpers/webtorrent' | |||
27 | export type VideoFormattingJSONOptions = { | 27 | export type VideoFormattingJSONOptions = { |
28 | completeDescription?: boolean | 28 | completeDescription?: boolean |
29 | additionalAttributes: { | 29 | additionalAttributes: { |
30 | state?: boolean, | 30 | state?: boolean |
31 | waitTranscoding?: boolean, | 31 | waitTranscoding?: boolean |
32 | scheduledUpdate?: boolean, | 32 | scheduledUpdate?: boolean |
33 | blacklistInfo?: boolean | 33 | blacklistInfo?: boolean |
34 | } | 34 | } |
35 | } | 35 | } |
36 | |||
36 | function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFormattingJSONOptions): Video { | 37 | function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFormattingJSONOptions): Video { |
37 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined | 38 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined |
38 | 39 | ||
@@ -181,12 +182,10 @@ function videoFilesModelToFormattedJSON ( | |||
181 | ): VideoFile[] { | 182 | ): VideoFile[] { |
182 | return videoFiles | 183 | return videoFiles |
183 | .map(videoFile => { | 184 | .map(videoFile => { |
184 | let resolutionLabel = videoFile.resolution + 'p' | ||
185 | |||
186 | return { | 185 | return { |
187 | resolution: { | 186 | resolution: { |
188 | id: videoFile.resolution, | 187 | id: videoFile.resolution, |
189 | label: resolutionLabel | 188 | label: videoFile.resolution + 'p' |
190 | }, | 189 | }, |
191 | magnetUri: generateMagnetUri(model, videoFile, baseUrlHttp, baseUrlWs), | 190 | magnetUri: generateMagnetUri(model, videoFile, baseUrlHttp, baseUrlWs), |
192 | size: videoFile.size, | 191 | size: videoFile.size, |
@@ -214,7 +213,7 @@ function addVideoFilesInAPAcc ( | |||
214 | for (const file of files) { | 213 | for (const file of files) { |
215 | acc.push({ | 214 | acc.push({ |
216 | type: 'Link', | 215 | type: 'Link', |
217 | mediaType: MIMETYPES.VIDEO.EXT_MIMETYPE[ file.extname ] as any, | 216 | mediaType: MIMETYPES.VIDEO.EXT_MIMETYPE[file.extname] as any, |
218 | href: model.getVideoFileUrl(file, baseUrlHttp), | 217 | href: model.getVideoFileUrl(file, baseUrlHttp), |
219 | height: file.resolution, | 218 | height: file.resolution, |
220 | size: file.size, | 219 | size: file.size, |
@@ -282,10 +281,8 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject { | |||
282 | addVideoFilesInAPAcc(url, video, baseUrlHttp, baseUrlWs, video.VideoFiles || []) | 281 | addVideoFilesInAPAcc(url, video, baseUrlHttp, baseUrlWs, video.VideoFiles || []) |
283 | 282 | ||
284 | for (const playlist of (video.VideoStreamingPlaylists || [])) { | 283 | for (const playlist of (video.VideoStreamingPlaylists || [])) { |
285 | let tag: ActivityTagObject[] | 284 | const tag = playlist.p2pMediaLoaderInfohashes |
286 | 285 | .map(i => ({ type: 'Infohash' as 'Infohash', name: i })) as ActivityTagObject[] | |
287 | tag = playlist.p2pMediaLoaderInfohashes | ||
288 | .map(i => ({ type: 'Infohash' as 'Infohash', name: i })) | ||
289 | tag.push({ | 286 | tag.push({ |
290 | type: 'Link', | 287 | type: 'Link', |
291 | name: 'sha256', | 288 | name: 'sha256', |
@@ -308,11 +305,12 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject { | |||
308 | for (const caption of video.VideoCaptions) { | 305 | for (const caption of video.VideoCaptions) { |
309 | subtitleLanguage.push({ | 306 | subtitleLanguage.push({ |
310 | identifier: caption.language, | 307 | identifier: caption.language, |
311 | name: VideoCaptionModel.getLanguageLabel(caption.language) | 308 | name: VideoCaptionModel.getLanguageLabel(caption.language), |
309 | url: caption.getFileUrl(video) | ||
312 | }) | 310 | }) |
313 | } | 311 | } |
314 | 312 | ||
315 | const miniature = video.getMiniature() | 313 | const icons = [ video.getMiniature(), video.getPreview() ] |
316 | 314 | ||
317 | return { | 315 | return { |
318 | type: 'Video' as 'Video', | 316 | type: 'Video' as 'Video', |
@@ -337,13 +335,13 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject { | |||
337 | content: video.getTruncatedDescription(), | 335 | content: video.getTruncatedDescription(), |
338 | support: video.support, | 336 | support: video.support, |
339 | subtitleLanguage, | 337 | subtitleLanguage, |
340 | icon: { | 338 | icon: icons.map(i => ({ |
341 | type: 'Image', | 339 | type: 'Image', |
342 | url: miniature.getFileUrl(video.isOwned()), | 340 | url: i.getFileUrl(video), |
343 | mediaType: 'image/jpeg', | 341 | mediaType: 'image/jpeg', |
344 | width: miniature.width, | 342 | width: i.width, |
345 | height: miniature.height | 343 | height: i.height |
346 | }, | 344 | })), |
347 | url, | 345 | url, |
348 | likes: getVideoLikesActivityPubUrl(video), | 346 | likes: getVideoLikesActivityPubUrl(video), |
349 | dislikes: getVideoDislikesActivityPubUrl(video), | 347 | dislikes: getVideoDislikesActivityPubUrl(video), |