]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/sql/shared/video-attributes.ts
Use separate queries for video files
[github/Chocobozzz/PeerTube.git] / server / models / video / sql / shared / video-attributes.ts
CommitLineData
1d43c3a6
C
1
2/**
3 *
4 * Class to build video attributes we want to fetch from the database
5 *
6 */
d9bf974f
C
7export class VideoAttributes {
8
9 constructor (readonly mode: 'get' | 'list') {
10
11 }
12
13 getChannelAttributes () {
14 let attributeKeys = [
15 'id',
16 'name',
17 'description',
18 'actorId'
19 ]
20
21 if (this.mode === 'get') {
22 attributeKeys = attributeKeys.concat([
23 'support',
24 'createdAt',
25 'updatedAt'
26 ])
27 }
28
29 return attributeKeys
30 }
31
32 getAccountAttributes () {
33 let attributeKeys = [ 'id', 'name', 'actorId' ]
34
35 if (this.mode === 'get') {
36 attributeKeys = attributeKeys.concat([
37 'description',
38 'createdAt',
39 'updatedAt'
40 ])
41 }
42
43 return attributeKeys
44 }
45
46 getThumbnailAttributes () {
47 let attributeKeys = [ 'id', 'type', 'filename' ]
48
49 if (this.mode === 'get') {
50 attributeKeys = attributeKeys.concat([
51 'height',
52 'width',
53 'fileUrl',
54 'automaticallyGenerated',
55 'videoId',
56 'videoPlaylistId',
57 'createdAt',
58 'updatedAt'
59 ])
60 }
61
62 return attributeKeys
63 }
64
65 getFileAttributes () {
66 return [
67 'id',
68 'createdAt',
69 'updatedAt',
70 'resolution',
71 'size',
72 'extname',
73 'filename',
74 'fileUrl',
75 'torrentFilename',
76 'torrentUrl',
77 'infoHash',
78 'fps',
79 'metadataUrl',
80 'videoStreamingPlaylistId',
81 'videoId'
82 ]
83 }
84
85 getStreamingPlaylistAttributes () {
86 let playlistKeys = [ 'id', 'playlistUrl', 'type' ]
87
88 if (this.mode === 'get') {
89 playlistKeys = playlistKeys.concat([
90 'p2pMediaLoaderInfohashes',
91 'p2pMediaLoaderPeerVersion',
92 'segmentsSha256Url',
93 'videoId',
94 'createdAt',
95 'updatedAt'
96 ])
97 }
98
99 return playlistKeys
100 }
101
102 getUserHistoryAttributes () {
103 return [ 'id', 'currentTime' ]
104 }
105
106 getPlaylistAttributes () {
107 return [
108 'createdAt',
109 'updatedAt',
110 'url',
111 'position',
112 'startTimestamp',
113 'stopTimestamp',
114 'videoPlaylistId'
115 ]
116 }
117
118 getTagAttributes () {
119 return [ 'id', 'name' ]
120 }
121
122 getVideoTagAttributes () {
123 return [ 'videoId', 'tagId', 'createdAt', 'updatedAt' ]
124 }
125
126 getBlacklistedAttributes () {
127 return [ 'id', 'reason', 'unfederated' ]
128 }
129
130 getScheduleUpdateAttributes () {
131 return [
132 'id',
133 'updateAt',
134 'privacy',
135 'videoId',
136 'createdAt',
137 'updatedAt'
138 ]
139 }
140
141 getLiveAttributes () {
142 return [
143 'id',
144 'streamKey',
145 'saveReplay',
146 'permanentLive',
147 'videoId',
148 'createdAt',
149 'updatedAt'
150 ]
151 }
152
153 getTrackerAttributes () {
154 return [ 'id', 'url' ]
155 }
156
157 getVideoTrackerAttributes () {
158 return [
159 'videoId',
160 'trackerId',
161 'createdAt',
162 'updatedAt'
163 ]
164 }
165
166 getRedundancyAttributes () {
167 return [ 'id', 'fileUrl' ]
168 }
169
170 getActorAttributes () {
171 let attributeKeys = [
172 'id',
173 'preferredUsername',
174 'url',
175 'serverId',
176 'avatarId'
177 ]
178
179 if (this.mode === 'get') {
180 attributeKeys = attributeKeys.concat([
181 'type',
182 'followersCount',
183 'followingCount',
184 'inboxUrl',
185 'outboxUrl',
186 'sharedInboxUrl',
187 'followersUrl',
188 'followingUrl',
189 'remoteCreatedAt',
190 'createdAt',
191 'updatedAt'
192 ])
193 }
194
195 return attributeKeys
196 }
197
198 getAvatarAttributes () {
199 let attributeKeys = [
200 'id',
201 'filename',
202 'fileUrl',
203 'onDisk',
204 'createdAt',
205 'updatedAt'
206 ]
207
208 if (this.mode === 'get') {
209 attributeKeys = attributeKeys.concat([
210 'height',
211 'width',
212 'type'
213 ])
214 }
215
216 return attributeKeys
217 }
218
219 getServerAttributes () {
220 return [ 'id', 'host' ]
221 }
222
223 getVideoAttributes () {
224 return [
225 'id',
226 'uuid',
227 'name',
228 'category',
229 'licence',
230 'language',
231 'privacy',
232 'nsfw',
233 'description',
234 'support',
235 'duration',
236 'views',
237 'likes',
238 'dislikes',
239 'remote',
240 'isLive',
241 'url',
242 'commentsEnabled',
243 'downloadEnabled',
244 'waitTranscoding',
245 'state',
246 'publishedAt',
247 'originallyPublishedAt',
248 'channelId',
249 'createdAt',
250 'updatedAt'
251 ]
252 }
253}