-function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo, user: UserModel) {
- const videoData = {
- name: body.name || importData.name || 'Unknown name',
- remote: false,
- category: body.category || importData.category,
- licence: body.licence || importData.licence,
- language: body.language || undefined,
- commentsEnabled: body.commentsEnabled || true,
- downloadEnabled: body.downloadEnabled || true,
- waitTranscoding: body.waitTranscoding || false,
- state: VideoState.TO_IMPORT,
- nsfw: body.nsfw || importData.nsfw || false,
- description: body.description || importData.description,
- support: body.support || null,
- privacy: body.privacy || VideoPrivacy.PRIVATE,
- duration: 0, // duration will be set by the import job
- channelId: channelId,
- originallyPublishedAt: importData.originallyPublishedAt
+async function processPreview (req: express.Request, video: MVideoThumbnail): Promise<MThumbnail> {
+ const previewField = req.files ? req.files['previewfile'] : undefined
+ if (previewField) {
+ const previewPhysicalFile = previewField[0]
+
+ return updateVideoMiniatureFromExisting({
+ inputPath: previewPhysicalFile.path,
+ video,
+ type: ThumbnailType.PREVIEW,
+ automaticallyGenerated: false
+ })