aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-format-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-format-utils.ts')
-rw-r--r--server/models/video/video-format-utils.ts36
1 files changed, 15 insertions, 21 deletions
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index a62335333..dc10fb9a2 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -26,12 +26,10 @@ export type VideoFormattingJSONOptions = {
26 waitTranscoding?: boolean, 26 waitTranscoding?: boolean,
27 scheduledUpdate?: boolean, 27 scheduledUpdate?: boolean,
28 blacklistInfo?: boolean 28 blacklistInfo?: boolean
29 playlistInfo?: boolean
29 } 30 }
30} 31}
31function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video { 32function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video {
32 const formattedAccount = video.VideoChannel.Account.toFormattedJSON()
33 const formattedVideoChannel = video.VideoChannel.toFormattedJSON()
34
35 const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined 33 const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined
36 34
37 const videoObject: Video = { 35 const videoObject: Video = {
@@ -68,24 +66,9 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting
68 updatedAt: video.updatedAt, 66 updatedAt: video.updatedAt,
69 publishedAt: video.publishedAt, 67 publishedAt: video.publishedAt,
70 originallyPublishedAt: video.originallyPublishedAt, 68 originallyPublishedAt: video.originallyPublishedAt,
71 account: { 69
72 id: formattedAccount.id, 70 account: video.VideoChannel.Account.toFormattedSummaryJSON(),
73 uuid: formattedAccount.uuid, 71 channel: video.VideoChannel.toFormattedSummaryJSON(),
74 name: formattedAccount.name,
75 displayName: formattedAccount.displayName,
76 url: formattedAccount.url,
77 host: formattedAccount.host,
78 avatar: formattedAccount.avatar
79 },
80 channel: {
81 id: formattedVideoChannel.id,
82 uuid: formattedVideoChannel.uuid,
83 name: formattedVideoChannel.name,
84 displayName: formattedVideoChannel.displayName,
85 url: formattedVideoChannel.url,
86 host: formattedVideoChannel.host,
87 avatar: formattedVideoChannel.avatar
88 },
89 72
90 userHistory: userHistory ? { 73 userHistory: userHistory ? {
91 currentTime: userHistory.currentTime 74 currentTime: userHistory.currentTime
@@ -115,6 +98,17 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormatting
115 videoObject.blacklisted = !!video.VideoBlacklist 98 videoObject.blacklisted = !!video.VideoBlacklist
116 videoObject.blacklistedReason = video.VideoBlacklist ? video.VideoBlacklist.reason : null 99 videoObject.blacklistedReason = video.VideoBlacklist ? video.VideoBlacklist.reason : null
117 } 100 }
101
102 if (options.additionalAttributes.playlistInfo === true) {
103 // We filtered on a specific videoId/videoPlaylistId, that is unique
104 const playlistElement = video.VideoPlaylistElements[0]
105
106 videoObject.playlistElement = {
107 position: playlistElement.position,
108 startTimestamp: playlistElement.startTimestamp,
109 stopTimestamp: playlistElement.stopTimestamp
110 }
111 }
118 } 112 }
119 113
120 return videoObject 114 return videoObject