aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r--server/lib/job-queue/handlers/video-import.ts21
1 files changed, 6 insertions, 15 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index 9125b50e1..1e5e52b58 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -57,10 +57,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP
57 57
58 const options = { 58 const options = {
59 type: payload.type, 59 type: payload.type,
60 videoImportId: payload.videoImportId, 60 videoImportId: payload.videoImportId
61
62 generateThumbnail: true,
63 generatePreview: true
64 } 61 }
65 const target = { 62 const target = {
66 torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined, 63 torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined,
@@ -75,10 +72,7 @@ async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutub
75 const videoImport = await getVideoImportOrDie(payload.videoImportId) 72 const videoImport = await getVideoImportOrDie(payload.videoImportId)
76 const options = { 73 const options = {
77 type: payload.type, 74 type: payload.type,
78 videoImportId: videoImport.id, 75 videoImportId: videoImport.id
79
80 generateThumbnail: payload.generateThumbnail,
81 generatePreview: payload.generatePreview
82 } 76 }
83 77
84 return processFile( 78 return processFile(
@@ -100,9 +94,6 @@ async function getVideoImportOrDie (videoImportId: number) {
100type ProcessFileOptions = { 94type ProcessFileOptions = {
101 type: VideoImportYoutubeDLPayloadType | VideoImportTorrentPayloadType 95 type: VideoImportYoutubeDLPayloadType | VideoImportTorrentPayloadType
102 videoImportId: number 96 videoImportId: number
103
104 generateThumbnail: boolean
105 generatePreview: boolean
106} 97}
107async function processFile (downloader: () => Promise<string>, videoImport: MVideoImportDefault, options: ProcessFileOptions) { 98async function processFile (downloader: () => Promise<string>, videoImport: MVideoImportDefault, options: ProcessFileOptions) {
108 let tempVideoPath: string 99 let tempVideoPath: string
@@ -167,18 +158,18 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid
167 await move(tempVideoPath, videoDestFile) 158 await move(tempVideoPath, videoDestFile)
168 tempVideoPath = null // This path is not used anymore 159 tempVideoPath = null // This path is not used anymore
169 160
170 // Process thumbnail 161 // Generate miniature if the import did not created it
171 let thumbnailModel: MThumbnail 162 let thumbnailModel: MThumbnail
172 let thumbnailSave: object 163 let thumbnailSave: object
173 if (options.generateThumbnail) { 164 if (!videoImportWithFiles.Video.getMiniature()) {
174 thumbnailModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.MINIATURE) 165 thumbnailModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.MINIATURE)
175 thumbnailSave = thumbnailModel.toJSON() 166 thumbnailSave = thumbnailModel.toJSON()
176 } 167 }
177 168
178 // Process preview 169 // Generate preview if the import did not created it
179 let previewModel: MThumbnail 170 let previewModel: MThumbnail
180 let previewSave: object 171 let previewSave: object
181 if (options.generatePreview) { 172 if (!videoImportWithFiles.Video.getPreview()) {
182 previewModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.PREVIEW) 173 previewModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.PREVIEW)
183 previewSave = previewModel.toJSON() 174 previewSave = previewModel.toJSON()
184 } 175 }