aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/video-playlist.ts19
-rw-r--r--server/controllers/api/videos/import.ts10
-rw-r--r--server/controllers/api/videos/index.ts2
3 files changed, 23 insertions, 8 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index f3dc8b2a9..aab16533d 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -173,7 +173,11 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
173 173
174 const thumbnailField = req.files['thumbnailfile'] 174 const thumbnailField = req.files['thumbnailfile']
175 const thumbnailModel = thumbnailField 175 const thumbnailModel = thumbnailField
176 ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylist, false) 176 ? await createPlaylistMiniatureFromExisting({
177 inputPath: thumbnailField[0].path,
178 playlist: videoPlaylist,
179 automaticallyGenerated: false
180 })
177 : undefined 181 : undefined
178 182
179 const videoPlaylistCreated = await sequelizeTypescript.transaction(async t => { 183 const videoPlaylistCreated = await sequelizeTypescript.transaction(async t => {
@@ -211,7 +215,11 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
211 215
212 const thumbnailField = req.files['thumbnailfile'] 216 const thumbnailField = req.files['thumbnailfile']
213 const thumbnailModel = thumbnailField 217 const thumbnailModel = thumbnailField
214 ? await createPlaylistMiniatureFromExisting(thumbnailField[0].path, videoPlaylistInstance, false) 218 ? await createPlaylistMiniatureFromExisting({
219 inputPath: thumbnailField[0].path,
220 playlist: videoPlaylistInstance,
221 automaticallyGenerated: false
222 })
215 : undefined 223 : undefined
216 224
217 try { 225 try {
@@ -474,7 +482,12 @@ async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbn
474 } 482 }
475 483
476 const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename) 484 const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
477 const thumbnailModel = await createPlaylistMiniatureFromExisting(inputPath, videoPlaylist, true, true) 485 const thumbnailModel = await createPlaylistMiniatureFromExisting({
486 inputPath,
487 playlist: videoPlaylist,
488 automaticallyGenerated: true,
489 keepOriginal: true
490 })
478 491
479 thumbnailModel.videoPlaylistId = videoPlaylist.id 492 thumbnailModel.videoPlaylistId = videoPlaylist.id
480 493
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index c689cb6f9..3b9b887e2 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -282,7 +282,7 @@ async function processPreview (req: express.Request, video: MVideoThumbnail): Pr
282 282
283async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) { 283async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
284 try { 284 try {
285 return createVideoMiniatureFromUrl(url, video, ThumbnailType.MINIATURE) 285 return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.MINIATURE })
286 } catch (err) { 286 } catch (err) {
287 logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err }) 287 logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err })
288 return undefined 288 return undefined
@@ -291,14 +291,14 @@ async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
291 291
292async function processPreviewFromUrl (url: string, video: MVideoThumbnail) { 292async function processPreviewFromUrl (url: string, video: MVideoThumbnail) {
293 try { 293 try {
294 return createVideoMiniatureFromUrl(url, video, ThumbnailType.PREVIEW) 294 return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.PREVIEW })
295 } catch (err) { 295 } catch (err) {
296 logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err }) 296 logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err })
297 return undefined 297 return undefined
298 } 298 }
299} 299}
300 300
301function insertIntoDB (parameters: { 301async function insertIntoDB (parameters: {
302 video: MVideoThumbnail 302 video: MVideoThumbnail
303 thumbnailModel: MThumbnail 303 thumbnailModel: MThumbnail
304 previewModel: MThumbnail 304 previewModel: MThumbnail
@@ -309,7 +309,7 @@ function insertIntoDB (parameters: {
309}): Promise<MVideoImportFormattable> { 309}): Promise<MVideoImportFormattable> {
310 const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters 310 const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters
311 311
312 return sequelizeTypescript.transaction(async t => { 312 const videoImport = await sequelizeTypescript.transaction(async t => {
313 const sequelizeOptions = { transaction: t } 313 const sequelizeOptions = { transaction: t }
314 314
315 // Save video object in database 315 // Save video object in database
@@ -339,4 +339,6 @@ function insertIntoDB (parameters: {
339 339
340 return videoImport 340 return videoImport
341 }) 341 })
342
343 return videoImport
342} 344}
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index c2c5eb640..9504c40a4 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -215,7 +215,7 @@ async function addVideo (req: express.Request, res: express.Response) {
215 const [ thumbnailModel, previewModel ] = await buildVideoThumbnailsFromReq({ 215 const [ thumbnailModel, previewModel ] = await buildVideoThumbnailsFromReq({
216 video, 216 video,
217 files: req.files, 217 files: req.files,
218 fallback: type => generateVideoMiniature(video, videoFile, type) 218 fallback: type => generateVideoMiniature({ video, videoFile, type })
219 }) 219 })
220 220
221 // Create the torrent file 221 // Create the torrent file