diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-26 10:55:40 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (patch) | |
tree | 5e9bc5604fd5d66a006cfebb7acdbdd5486e5d1e /server/models/video/video-format-utils.ts | |
parent | b427febb4d5cebf03b815bca2c59af6e82491569 (diff) | |
download | PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.gz PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.zst PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.zip |
Playlist server API
Diffstat (limited to 'server/models/video/video-format-utils.ts')
-rw-r--r-- | server/models/video/video-format-utils.ts | 36 |
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 | } |
31 | function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video { | 32 | function 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 |