aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-11-16 16:48:17 +0100
committerChocobozzz <me@florianbigard.com>2018-11-16 16:48:17 +0100
commit58d515e32fe1d0133435b3a5e550c6ff24906fff (patch)
treee769b2f29bdb7bb626208f72fc765ba21a54e9ab /server/lib/job-queue/handlers
parentbabecc3c09cd4ed06fe643a97fff4bcc31c5a9be (diff)
downloadPeerTube-58d515e32fe1d0133435b3a5e550c6ff24906fff.tar.gz
PeerTube-58d515e32fe1d0133435b3a5e550c6ff24906fff.tar.zst
PeerTube-58d515e32fe1d0133435b3a5e550c6ff24906fff.zip
Fix images size when downloading them
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/video-import.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index e3f2a276c..4de901c0c 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -6,8 +6,8 @@ import { VideoImportState } from '../../../../shared/models/videos'
6import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 6import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
7import { extname, join } from 'path' 7import { extname, join } from 'path'
8import { VideoFileModel } from '../../../models/video/video-file' 8import { VideoFileModel } from '../../../models/video/video-file'
9import { CONFIG, sequelizeTypescript, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' 9import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
10import { doRequestAndSaveToFile } from '../../../helpers/requests' 10import { doRequestAndSaveToFile, downloadImage } from '../../../helpers/requests'
11import { VideoState } from '../../../../shared' 11import { VideoState } from '../../../../shared'
12import { JobQueue } from '../index' 12import { JobQueue } from '../index'
13import { federateVideoIfNeeded } from '../../activitypub' 13import { federateVideoIfNeeded } from '../../activitypub'
@@ -133,7 +133,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
133 videoId: videoImport.videoId 133 videoId: videoImport.videoId
134 } 134 }
135 videoFile = new VideoFileModel(videoFileData) 135 videoFile = new VideoFileModel(videoFileData)
136 // Import if the import fails, to clean files 136 // To clean files if the import fails
137 videoImport.Video.VideoFiles = [ videoFile ] 137 videoImport.Video.VideoFiles = [ videoFile ]
138 138
139 // Move file 139 // Move file
@@ -145,7 +145,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
145 if (options.downloadThumbnail) { 145 if (options.downloadThumbnail) {
146 if (options.thumbnailUrl) { 146 if (options.thumbnailUrl) {
147 const destThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName()) 147 const destThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName())
148 await doRequestAndSaveToFile({ method: 'GET', uri: options.thumbnailUrl }, destThumbnailPath) 148 await downloadImage(options.thumbnailUrl, destThumbnailPath, THUMBNAILS_SIZE)
149 } else { 149 } else {
150 await videoImport.Video.createThumbnail(videoFile) 150 await videoImport.Video.createThumbnail(videoFile)
151 } 151 }
@@ -157,7 +157,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
157 if (options.downloadPreview) { 157 if (options.downloadPreview) {
158 if (options.thumbnailUrl) { 158 if (options.thumbnailUrl) {
159 const destPreviewPath = join(CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName()) 159 const destPreviewPath = join(CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName())
160 await doRequestAndSaveToFile({ method: 'GET', uri: options.thumbnailUrl }, destPreviewPath) 160 await downloadImage(options.thumbnailUrl, destPreviewPath, PREVIEWS_SIZE)
161 } else { 161 } else {
162 await videoImport.Video.createPreview(videoFile) 162 await videoImport.Video.createPreview(videoFile)
163 } 163 }