aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/handlers/video-file.ts')
-rw-r--r--server/lib/job-queue/handlers/video-file.ts29
1 files changed, 26 insertions, 3 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts
index 93f9e9fe7..38eb3511c 100644
--- a/server/lib/job-queue/handlers/video-file.ts
+++ b/server/lib/job-queue/handlers/video-file.ts
@@ -16,6 +16,28 @@ export type VideoFilePayload = {
16 isPortraitMode?: boolean 16 isPortraitMode?: boolean
17} 17}
18 18
19export type VideoImportPayload = {
20 videoUUID: string,
21 filePath: string
22}
23
24async function processVideoImport (job: kue.Job) {
25 const payload = job.data as VideoImportPayload
26 logger.info('Processing video import in job %d.', job.id)
27
28 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(payload.videoUUID)
29 // No video, maybe deleted?
30 if (!video) {
31 logger.info('Do not process job %d, video does not exist.', job.id, { videoUUID: video.uuid })
32 return undefined
33 }
34
35 await video.importVideoFile(payload.filePath)
36
37 await onVideoFileTranscoderOrImportSuccess(video)
38 return video
39}
40
19async function processVideoFile (job: kue.Job) { 41async function processVideoFile (job: kue.Job) {
20 const payload = job.data as VideoFilePayload 42 const payload = job.data as VideoFilePayload
21 logger.info('Processing video file in job %d.', job.id) 43 logger.info('Processing video file in job %d.', job.id)
@@ -30,7 +52,7 @@ async function processVideoFile (job: kue.Job) {
30 // Transcoding in other resolution 52 // Transcoding in other resolution
31 if (payload.resolution) { 53 if (payload.resolution) {
32 await video.transcodeOriginalVideofile(payload.resolution, payload.isPortraitMode) 54 await video.transcodeOriginalVideofile(payload.resolution, payload.isPortraitMode)
33 await onVideoFileTranscoderSuccess(video) 55 await onVideoFileTranscoderOrImportSuccess(video)
34 } else { 56 } else {
35 await video.optimizeOriginalVideofile() 57 await video.optimizeOriginalVideofile()
36 await onVideoFileOptimizerSuccess(video, payload.isNewVideo) 58 await onVideoFileOptimizerSuccess(video, payload.isNewVideo)
@@ -39,7 +61,7 @@ async function processVideoFile (job: kue.Job) {
39 return video 61 return video
40} 62}
41 63
42async function onVideoFileTranscoderSuccess (video: VideoModel) { 64async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) {
43 if (video === undefined) return undefined 65 if (video === undefined) return undefined
44 66
45 // Maybe the video changed in database, refresh it 67 // Maybe the video changed in database, refresh it
@@ -109,5 +131,6 @@ async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boole
109// --------------------------------------------------------------------------- 131// ---------------------------------------------------------------------------
110 132
111export { 133export {
112 processVideoFile 134 processVideoFile,
135 processVideoImport
113} 136}