]>
Commit | Line | Data |
---|---|---|
1 | import * as express from 'express' | |
2 | import { join } from 'path' | |
3 | import { getServerActor } from '@server/models/application/application' | |
4 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' | |
5 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' | |
6 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' | |
7 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | |
8 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | |
9 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' | |
10 | import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model' | |
11 | import { resetSequelizeInstance } from '../../helpers/database-utils' | |
12 | import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' | |
13 | import { logger } from '../../helpers/logger' | |
14 | import { getFormattedObjects } from '../../helpers/utils' | |
15 | import { CONFIG } from '../../initializers/config' | |
16 | import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants' | |
17 | import { sequelizeTypescript } from '../../initializers/database' | |
18 | import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' | |
19 | import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' | |
20 | import { JobQueue } from '../../lib/job-queue' | |
21 | import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' | |
22 | import { | |
23 | asyncMiddleware, | |
24 | asyncRetryTransactionMiddleware, | |
25 | authenticate, | |
26 | optionalAuthenticate, | |
27 | paginationValidator, | |
28 | setDefaultPagination, | |
29 | setDefaultSort | |
30 | } from '../../middlewares' | |
31 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' | |
32 | import { | |
33 | commonVideoPlaylistFiltersValidator, | |
34 | videoPlaylistsAddValidator, | |
35 | videoPlaylistsAddVideoValidator, | |
36 | videoPlaylistsDeleteValidator, | |
37 | videoPlaylistsGetValidator, | |
38 | videoPlaylistsReorderVideosValidator, | |
39 | videoPlaylistsUpdateOrRemoveVideoValidator, | |
40 | videoPlaylistsUpdateValidator | |
41 | } from '../../middlewares/validators/videos/video-playlists' | |
42 | import { AccountModel } from '../../models/account/account' | |
43 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | |
44 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | |
45 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | |
46 | ||
47 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | |
48 | ||
49 | const videoPlaylistRouter = express.Router() | |
50 | ||
51 | videoPlaylistRouter.get('/privacies', listVideoPlaylistPrivacies) | |
52 | ||
53 | videoPlaylistRouter.get('/', | |
54 | paginationValidator, | |
55 | videoPlaylistsSortValidator, | |
56 | setDefaultSort, | |
57 | setDefaultPagination, | |
58 | commonVideoPlaylistFiltersValidator, | |
59 | asyncMiddleware(listVideoPlaylists) | |
60 | ) | |
61 | ||
62 | videoPlaylistRouter.get('/:playlistId', | |
63 | asyncMiddleware(videoPlaylistsGetValidator('summary')), | |
64 | getVideoPlaylist | |
65 | ) | |
66 | ||
67 | videoPlaylistRouter.post('/', | |
68 | authenticate, | |
69 | reqThumbnailFile, | |
70 | asyncMiddleware(videoPlaylistsAddValidator), | |
71 | asyncRetryTransactionMiddleware(addVideoPlaylist) | |
72 | ) | |
73 | ||
74 | videoPlaylistRouter.put('/:playlistId', | |
75 | authenticate, | |
76 | reqThumbnailFile, | |
77 | asyncMiddleware(videoPlaylistsUpdateValidator), | |
78 | asyncRetryTransactionMiddleware(updateVideoPlaylist) | |
79 | ) | |
80 | ||
81 | videoPlaylistRouter.delete('/:playlistId', | |
82 | authenticate, | |
83 | asyncMiddleware(videoPlaylistsDeleteValidator), | |
84 | asyncRetryTransactionMiddleware(removeVideoPlaylist) | |
85 | ) | |
86 | ||
87 | videoPlaylistRouter.get('/:playlistId/videos', | |
88 | asyncMiddleware(videoPlaylistsGetValidator('summary')), | |
89 | paginationValidator, | |
90 | setDefaultPagination, | |
91 | optionalAuthenticate, | |
92 | asyncMiddleware(getVideoPlaylistVideos) | |
93 | ) | |
94 | ||
95 | videoPlaylistRouter.post('/:playlistId/videos', | |
96 | authenticate, | |
97 | asyncMiddleware(videoPlaylistsAddVideoValidator), | |
98 | asyncRetryTransactionMiddleware(addVideoInPlaylist) | |
99 | ) | |
100 | ||
101 | videoPlaylistRouter.post('/:playlistId/videos/reorder', | |
102 | authenticate, | |
103 | asyncMiddleware(videoPlaylistsReorderVideosValidator), | |
104 | asyncRetryTransactionMiddleware(reorderVideosPlaylist) | |
105 | ) | |
106 | ||
107 | videoPlaylistRouter.put('/:playlistId/videos/:playlistElementId', | |
108 | authenticate, | |
109 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), | |
110 | asyncRetryTransactionMiddleware(updateVideoPlaylistElement) | |
111 | ) | |
112 | ||
113 | videoPlaylistRouter.delete('/:playlistId/videos/:playlistElementId', | |
114 | authenticate, | |
115 | asyncMiddleware(videoPlaylistsUpdateOrRemoveVideoValidator), | |
116 | asyncRetryTransactionMiddleware(removeVideoFromPlaylist) | |
117 | ) | |
118 | ||
119 | // --------------------------------------------------------------------------- | |
120 | ||
121 | export { | |
122 | videoPlaylistRouter | |
123 | } | |
124 | ||
125 | // --------------------------------------------------------------------------- | |
126 | ||
127 | function listVideoPlaylistPrivacies (req: express.Request, res: express.Response) { | |
128 | res.json(VIDEO_PLAYLIST_PRIVACIES) | |
129 | } | |
130 | ||
131 | async function listVideoPlaylists (req: express.Request, res: express.Response) { | |
132 | const serverActor = await getServerActor() | |
133 | const resultList = await VideoPlaylistModel.listForApi({ | |
134 | followerActorId: serverActor.id, | |
135 | start: req.query.start, | |
136 | count: req.query.count, | |
137 | sort: req.query.sort, | |
138 | type: req.query.type | |
139 | }) | |
140 | ||
141 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | |
142 | } | |
143 | ||
144 | function getVideoPlaylist (req: express.Request, res: express.Response) { | |
145 | const videoPlaylist = res.locals.videoPlaylistSummary | |
146 | ||
147 | if (videoPlaylist.isOutdated()) { | |
148 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video-playlist', url: videoPlaylist.url } }) | |
149 | } | |
150 | ||
151 | return res.json(videoPlaylist.toFormattedJSON()) | |
152 | } | |
153 | ||
154 | async function addVideoPlaylist (req: express.Request, res: express.Response) { | |
155 | const videoPlaylistInfo: VideoPlaylistCreate = req.body | |
156 | const user = res.locals.oauth.token.User | |
157 | ||
158 | const videoPlaylist = new VideoPlaylistModel({ | |
159 | name: videoPlaylistInfo.displayName, | |
160 | description: videoPlaylistInfo.description, | |
161 | privacy: videoPlaylistInfo.privacy || VideoPlaylistPrivacy.PRIVATE, | |
162 | ownerAccountId: user.Account.id | |
163 | }) as MVideoPlaylistFull | |
164 | ||
165 | videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object | |
166 | ||
167 | if (videoPlaylistInfo.videoChannelId) { | |
168 | const videoChannel = res.locals.videoChannel | |
169 | ||
170 | videoPlaylist.videoChannelId = videoChannel.id | |
171 | videoPlaylist.VideoChannel = videoChannel | |
172 | } | |
173 | ||
174 | const thumbnailField = req.files['thumbnailfile'] | |
175 | const thumbnailModel = thumbnailField | |
176 | ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylist, false) | |
177 | : undefined | |
178 | ||
179 | const videoPlaylistCreated = await sequelizeTypescript.transaction(async t => { | |
180 | const videoPlaylistCreated = await videoPlaylist.save({ transaction: t }) as MVideoPlaylistFull | |
181 | ||
182 | if (thumbnailModel) { | |
183 | thumbnailModel.automaticallyGenerated = false | |
184 | await videoPlaylistCreated.setAndSaveThumbnail(thumbnailModel, t) | |
185 | } | |
186 | ||
187 | // We need more attributes for the federation | |
188 | videoPlaylistCreated.OwnerAccount = await AccountModel.load(user.Account.id, t) | |
189 | await sendCreateVideoPlaylist(videoPlaylistCreated, t) | |
190 | ||
191 | return videoPlaylistCreated | |
192 | }) | |
193 | ||
194 | logger.info('Video playlist with uuid %s created.', videoPlaylist.uuid) | |
195 | ||
196 | return res.json({ | |
197 | videoPlaylist: { | |
198 | id: videoPlaylistCreated.id, | |
199 | uuid: videoPlaylistCreated.uuid | |
200 | } | |
201 | }).end() | |
202 | } | |
203 | ||
204 | async function updateVideoPlaylist (req: express.Request, res: express.Response) { | |
205 | const videoPlaylistInstance = res.locals.videoPlaylistFull | |
206 | const videoPlaylistFieldsSave = videoPlaylistInstance.toJSON() | |
207 | const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate | |
208 | ||
209 | const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE | |
210 | const wasNotPrivatePlaylist = videoPlaylistInstance.privacy !== VideoPlaylistPrivacy.PRIVATE | |
211 | ||
212 | const thumbnailField = req.files['thumbnailfile'] | |
213 | const thumbnailModel = thumbnailField | |
214 | ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylistInstance, false) | |
215 | : undefined | |
216 | ||
217 | try { | |
218 | await sequelizeTypescript.transaction(async t => { | |
219 | const sequelizeOptions = { | |
220 | transaction: t | |
221 | } | |
222 | ||
223 | if (videoPlaylistInfoToUpdate.videoChannelId !== undefined) { | |
224 | if (videoPlaylistInfoToUpdate.videoChannelId === null) { | |
225 | videoPlaylistInstance.videoChannelId = null | |
226 | } else { | |
227 | const videoChannel = res.locals.videoChannel | |
228 | ||
229 | videoPlaylistInstance.videoChannelId = videoChannel.id | |
230 | videoPlaylistInstance.VideoChannel = videoChannel | |
231 | } | |
232 | } | |
233 | ||
234 | if (videoPlaylistInfoToUpdate.displayName !== undefined) videoPlaylistInstance.name = videoPlaylistInfoToUpdate.displayName | |
235 | if (videoPlaylistInfoToUpdate.description !== undefined) videoPlaylistInstance.description = videoPlaylistInfoToUpdate.description | |
236 | ||
237 | if (videoPlaylistInfoToUpdate.privacy !== undefined) { | |
238 | videoPlaylistInstance.privacy = parseInt(videoPlaylistInfoToUpdate.privacy.toString(), 10) | |
239 | ||
240 | if (wasNotPrivatePlaylist === true && videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE) { | |
241 | await sendDeleteVideoPlaylist(videoPlaylistInstance, t) | |
242 | } | |
243 | } | |
244 | ||
245 | const playlistUpdated = await videoPlaylistInstance.save(sequelizeOptions) | |
246 | ||
247 | if (thumbnailModel) { | |
248 | thumbnailModel.automaticallyGenerated = false | |
249 | await playlistUpdated.setAndSaveThumbnail(thumbnailModel, t) | |
250 | } | |
251 | ||
252 | const isNewPlaylist = wasPrivatePlaylist && playlistUpdated.privacy !== VideoPlaylistPrivacy.PRIVATE | |
253 | ||
254 | if (isNewPlaylist) { | |
255 | await sendCreateVideoPlaylist(playlistUpdated, t) | |
256 | } else { | |
257 | await sendUpdateVideoPlaylist(playlistUpdated, t) | |
258 | } | |
259 | ||
260 | logger.info('Video playlist %s updated.', videoPlaylistInstance.uuid) | |
261 | ||
262 | return playlistUpdated | |
263 | }) | |
264 | } catch (err) { | |
265 | logger.debug('Cannot update the video playlist.', { err }) | |
266 | ||
267 | // Force fields we want to update | |
268 | // If the transaction is retried, sequelize will think the object has not changed | |
269 | // So it will skip the SQL request, even if the last one was ROLLBACKed! | |
270 | resetSequelizeInstance(videoPlaylistInstance, videoPlaylistFieldsSave) | |
271 | ||
272 | throw err | |
273 | } | |
274 | ||
275 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
276 | } | |
277 | ||
278 | async function removeVideoPlaylist (req: express.Request, res: express.Response) { | |
279 | const videoPlaylistInstance = res.locals.videoPlaylistSummary | |
280 | ||
281 | await sequelizeTypescript.transaction(async t => { | |
282 | await videoPlaylistInstance.destroy({ transaction: t }) | |
283 | ||
284 | await sendDeleteVideoPlaylist(videoPlaylistInstance, t) | |
285 | ||
286 | logger.info('Video playlist %s deleted.', videoPlaylistInstance.uuid) | |
287 | }) | |
288 | ||
289 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
290 | } | |
291 | ||
292 | async function addVideoInPlaylist (req: express.Request, res: express.Response) { | |
293 | const body: VideoPlaylistElementCreate = req.body | |
294 | const videoPlaylist = res.locals.videoPlaylistFull | |
295 | const video = res.locals.onlyVideo | |
296 | ||
297 | const playlistElement = await sequelizeTypescript.transaction(async t => { | |
298 | const position = await VideoPlaylistElementModel.getNextPositionOf(videoPlaylist.id, t) | |
299 | ||
300 | const playlistElement = await VideoPlaylistElementModel.create({ | |
301 | position, | |
302 | startTimestamp: body.startTimestamp || null, | |
303 | stopTimestamp: body.stopTimestamp || null, | |
304 | videoPlaylistId: videoPlaylist.id, | |
305 | videoId: video.id | |
306 | }, { transaction: t }) | |
307 | ||
308 | playlistElement.url = getLocalVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement) | |
309 | await playlistElement.save({ transaction: t }) | |
310 | ||
311 | videoPlaylist.changed('updatedAt', true) | |
312 | await videoPlaylist.save({ transaction: t }) | |
313 | ||
314 | return playlistElement | |
315 | }) | |
316 | ||
317 | // If the user did not set a thumbnail, automatically take the video thumbnail | |
318 | if (videoPlaylist.hasThumbnail() === false || (videoPlaylist.hasGeneratedThumbnail() && playlistElement.position === 1)) { | |
319 | await generateThumbnailForPlaylist(videoPlaylist, video) | |
320 | } | |
321 | ||
322 | sendUpdateVideoPlaylist(videoPlaylist, undefined) | |
323 | .catch(err => logger.error('Cannot send video playlist update.', { err })) | |
324 | ||
325 | logger.info('Video added in playlist %s at position %d.', videoPlaylist.uuid, playlistElement.position) | |
326 | ||
327 | return res.json({ | |
328 | videoPlaylistElement: { | |
329 | id: playlistElement.id | |
330 | } | |
331 | }).end() | |
332 | } | |
333 | ||
334 | async function updateVideoPlaylistElement (req: express.Request, res: express.Response) { | |
335 | const body: VideoPlaylistElementUpdate = req.body | |
336 | const videoPlaylist = res.locals.videoPlaylistFull | |
337 | const videoPlaylistElement = res.locals.videoPlaylistElement | |
338 | ||
339 | const playlistElement: VideoPlaylistElementModel = await sequelizeTypescript.transaction(async t => { | |
340 | if (body.startTimestamp !== undefined) videoPlaylistElement.startTimestamp = body.startTimestamp | |
341 | if (body.stopTimestamp !== undefined) videoPlaylistElement.stopTimestamp = body.stopTimestamp | |
342 | ||
343 | const element = await videoPlaylistElement.save({ transaction: t }) | |
344 | ||
345 | videoPlaylist.changed('updatedAt', true) | |
346 | await videoPlaylist.save({ transaction: t }) | |
347 | ||
348 | await sendUpdateVideoPlaylist(videoPlaylist, t) | |
349 | ||
350 | return element | |
351 | }) | |
352 | ||
353 | logger.info('Element of position %d of playlist %s updated.', playlistElement.position, videoPlaylist.uuid) | |
354 | ||
355 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
356 | } | |
357 | ||
358 | async function removeVideoFromPlaylist (req: express.Request, res: express.Response) { | |
359 | const videoPlaylistElement = res.locals.videoPlaylistElement | |
360 | const videoPlaylist = res.locals.videoPlaylistFull | |
361 | const positionToDelete = videoPlaylistElement.position | |
362 | ||
363 | await sequelizeTypescript.transaction(async t => { | |
364 | await videoPlaylistElement.destroy({ transaction: t }) | |
365 | ||
366 | // Decrease position of the next elements | |
367 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, positionToDelete, null, -1, t) | |
368 | ||
369 | videoPlaylist.changed('updatedAt', true) | |
370 | await videoPlaylist.save({ transaction: t }) | |
371 | ||
372 | logger.info('Video playlist element %d of playlist %s deleted.', videoPlaylistElement.position, videoPlaylist.uuid) | |
373 | }) | |
374 | ||
375 | // Do we need to regenerate the default thumbnail? | |
376 | if (positionToDelete === 1 && videoPlaylist.hasGeneratedThumbnail()) { | |
377 | await regeneratePlaylistThumbnail(videoPlaylist) | |
378 | } | |
379 | ||
380 | sendUpdateVideoPlaylist(videoPlaylist, undefined) | |
381 | .catch(err => logger.error('Cannot send video playlist update.', { err })) | |
382 | ||
383 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
384 | } | |
385 | ||
386 | async function reorderVideosPlaylist (req: express.Request, res: express.Response) { | |
387 | const videoPlaylist = res.locals.videoPlaylistFull | |
388 | const body: VideoPlaylistReorder = req.body | |
389 | ||
390 | const start: number = body.startPosition | |
391 | const insertAfter: number = body.insertAfterPosition | |
392 | const reorderLength: number = body.reorderLength || 1 | |
393 | ||
394 | if (start === insertAfter) { | |
395 | return res.status(HttpStatusCode.NO_CONTENT_204).end() | |
396 | } | |
397 | ||
398 | // Example: if we reorder position 2 and insert after position 5 (so at position 6): # 1 2 3 4 5 6 7 8 9 | |
399 | // * increase position when position > 5 # 1 2 3 4 5 7 8 9 10 | |
400 | // * update position 2 -> position 6 # 1 3 4 5 6 7 8 9 10 | |
401 | // * decrease position when position position > 2 # 1 2 3 4 5 6 7 8 9 | |
402 | await sequelizeTypescript.transaction(async t => { | |
403 | const newPosition = insertAfter + 1 | |
404 | ||
405 | // Add space after the position when we want to insert our reordered elements (increase) | |
406 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, newPosition, null, reorderLength, t) | |
407 | ||
408 | let oldPosition = start | |
409 | ||
410 | // We incremented the position of the elements we want to reorder | |
411 | if (start >= newPosition) oldPosition += reorderLength | |
412 | ||
413 | const endOldPosition = oldPosition + reorderLength - 1 | |
414 | // Insert our reordered elements in their place (update) | |
415 | await VideoPlaylistElementModel.reassignPositionOf(videoPlaylist.id, oldPosition, endOldPosition, newPosition, t) | |
416 | ||
417 | // Decrease positions of elements after the old position of our ordered elements (decrease) | |
418 | await VideoPlaylistElementModel.increasePositionOf(videoPlaylist.id, oldPosition, null, -reorderLength, t) | |
419 | ||
420 | videoPlaylist.changed('updatedAt', true) | |
421 | await videoPlaylist.save({ transaction: t }) | |
422 | ||
423 | await sendUpdateVideoPlaylist(videoPlaylist, t) | |
424 | }) | |
425 | ||
426 | // The first element changed | |
427 | if ((start === 1 || insertAfter === 0) && videoPlaylist.hasGeneratedThumbnail()) { | |
428 | await regeneratePlaylistThumbnail(videoPlaylist) | |
429 | } | |
430 | ||
431 | logger.info( | |
432 | 'Reordered playlist %s (inserted after position %d elements %d - %d).', | |
433 | videoPlaylist.uuid, insertAfter, start, start + reorderLength - 1 | |
434 | ) | |
435 | ||
436 | return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end() | |
437 | } | |
438 | ||
439 | async function getVideoPlaylistVideos (req: express.Request, res: express.Response) { | |
440 | const videoPlaylistInstance = res.locals.videoPlaylistSummary | |
441 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined | |
442 | const server = await getServerActor() | |
443 | ||
444 | const resultList = await VideoPlaylistElementModel.listForApi({ | |
445 | start: req.query.start, | |
446 | count: req.query.count, | |
447 | videoPlaylistId: videoPlaylistInstance.id, | |
448 | serverAccount: server.Account, | |
449 | user | |
450 | }) | |
451 | ||
452 | const options = { | |
453 | displayNSFW: buildNSFWFilter(res, req.query.nsfw), | |
454 | accountId: user ? user.Account.id : undefined | |
455 | } | |
456 | return res.json(getFormattedObjects(resultList.data, resultList.total, options)) | |
457 | } | |
458 | ||
459 | async function regeneratePlaylistThumbnail (videoPlaylist: MVideoPlaylistThumbnail) { | |
460 | await videoPlaylist.Thumbnail.destroy() | |
461 | videoPlaylist.Thumbnail = null | |
462 | ||
463 | const firstElement = await VideoPlaylistElementModel.loadFirstElementWithVideoThumbnail(videoPlaylist.id) | |
464 | if (firstElement) await generateThumbnailForPlaylist(videoPlaylist, firstElement.Video) | |
465 | } | |
466 | ||
467 | async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbnail, video: MVideoThumbnail) { | |
468 | logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url) | |
469 | ||
470 | const videoMiniature = video.getMiniature() | |
471 | if (!videoMiniature) { | |
472 | logger.info('Cannot generate thumbnail for playlist %s because video %s does not have any.', videoPlaylist.url, video.url) | |
473 | return | |
474 | } | |
475 | ||
476 | const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename) | |
477 | const thumbnailModel = await createPlaylistMiniatureFromExisting(inputPath, videoPlaylist, true, true) | |
478 | ||
479 | thumbnailModel.videoPlaylistId = videoPlaylist.id | |
480 | ||
481 | videoPlaylist.Thumbnail = await thumbnailModel.save() | |
482 | } |