diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-12 09:37:01 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-12 09:37:01 +0100 |
commit | e3b4c084cd0935dd93b1d737c4fc88c65ab5bcc1 (patch) | |
tree | 5d7cbffb47a53d192265103f49a14ac6b504daca /server/lib | |
parent | 06bee93748db63d25b8f3b24cd0eeba97a0bbfda (diff) | |
download | PeerTube-e3b4c084cd0935dd93b1d737c4fc88c65ab5bcc1.tar.gz PeerTube-e3b4c084cd0935dd93b1d737c4fc88c65ab5bcc1.tar.zst PeerTube-e3b4c084cd0935dd93b1d737c4fc88c65ab5bcc1.zip |
Guess if we need to generate the thumbnail for imports
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 21 |
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) { | |||
100 | type ProcessFileOptions = { | 94 | type ProcessFileOptions = { |
101 | type: VideoImportYoutubeDLPayloadType | VideoImportTorrentPayloadType | 95 | type: VideoImportYoutubeDLPayloadType | VideoImportTorrentPayloadType |
102 | videoImportId: number | 96 | videoImportId: number |
103 | |||
104 | generateThumbnail: boolean | ||
105 | generatePreview: boolean | ||
106 | } | 97 | } |
107 | async function processFile (downloader: () => Promise<string>, videoImport: MVideoImportDefault, options: ProcessFileOptions) { | 98 | async 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 | } |