aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/videos/import.ts2
-rw-r--r--server/lib/job-queue/handlers/video-import.ts21
-rw-r--r--shared/models/server/job.model.ts2
3 files changed, 6 insertions, 19 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 96499dffb..01f41e7bc 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -218,8 +218,6 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
218 const payload = { 218 const payload = {
219 type: 'youtube-dl' as 'youtube-dl', 219 type: 'youtube-dl' as 'youtube-dl',
220 videoImportId: videoImport.id, 220 videoImportId: videoImport.id,
221 generateThumbnail: !thumbnailModel,
222 generatePreview: !previewModel,
223 fileExt: `.${youtubeDLInfo.ext || 'mp4'}` 221 fileExt: `.${youtubeDLInfo.ext || 'mp4'}`
224 } 222 }
225 await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) 223 await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload })
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 }
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts
index 44f92abf1..07d7efe22 100644
--- a/shared/models/server/job.model.ts
+++ b/shared/models/server/job.model.ts
@@ -80,8 +80,6 @@ export type VideoImportYoutubeDLPayload = {
80 type: VideoImportYoutubeDLPayloadType 80 type: VideoImportYoutubeDLPayloadType
81 videoImportId: number 81 videoImportId: number
82 82
83 generateThumbnail: boolean
84 generatePreview: boolean
85 fileExt?: string 83 fileExt?: string
86} 84}
87export type VideoImportTorrentPayload = { 85export type VideoImportTorrentPayload = {