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