diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/videos/import.ts | 5 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 28 |
2 files changed, 9 insertions, 24 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index ed223cbc9..da0832258 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -174,7 +174,10 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
174 | videoImportId: videoImport.id, | 174 | videoImportId: videoImport.id, |
175 | thumbnailUrl: youtubeDLInfo.thumbnailUrl, | 175 | thumbnailUrl: youtubeDLInfo.thumbnailUrl, |
176 | downloadThumbnail: !thumbnailModel, | 176 | downloadThumbnail: !thumbnailModel, |
177 | downloadPreview: !previewModel | 177 | downloadPreview: !previewModel, |
178 | fileExt: youtubeDLInfo.fileExt | ||
179 | ? `.${youtubeDLInfo.fileExt}` | ||
180 | : '.mp4' | ||
178 | } | 181 | } |
179 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) | 182 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) |
180 | 183 | ||
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 9b19c394d..04d775cbf 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { extname } from 'path' | 2 | import { extname } from 'path' |
3 | import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' | 3 | import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' |
4 | import { getVideoFileFPS, getVideoFileResolution, getMetadataFromFile } from '../../../helpers/ffmpeg-utils' | 4 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
7 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 7 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
@@ -32,13 +32,13 @@ import { | |||
32 | paginationValidator, | 32 | paginationValidator, |
33 | setDefaultPagination, | 33 | setDefaultPagination, |
34 | setDefaultSort, | 34 | setDefaultSort, |
35 | videoFileMetadataGetValidator, | ||
35 | videosAddValidator, | 36 | videosAddValidator, |
36 | videosCustomGetValidator, | 37 | videosCustomGetValidator, |
37 | videosGetValidator, | 38 | videosGetValidator, |
38 | videosRemoveValidator, | 39 | videosRemoveValidator, |
39 | videosSortValidator, | 40 | videosSortValidator, |
40 | videosUpdateValidator, | 41 | videosUpdateValidator |
41 | videoFileMetadataGetValidator | ||
42 | } from '../../../middlewares' | 42 | } from '../../../middlewares' |
43 | import { TagModel } from '../../../models/video/tag' | 43 | import { TagModel } from '../../../models/video/tag' |
44 | import { VideoModel } from '../../../models/video/video' | 44 | import { VideoModel } from '../../../models/video/video' |
@@ -62,12 +62,12 @@ import { CONFIG } from '../../../initializers/config' | |||
62 | import { sequelizeTypescript } from '../../../initializers/database' | 62 | import { sequelizeTypescript } from '../../../initializers/database' |
63 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' | 63 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' |
64 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 64 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
65 | import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding' | ||
66 | import { Hooks } from '../../../lib/plugins/hooks' | 65 | import { Hooks } from '../../../lib/plugins/hooks' |
67 | import { MVideoDetails, MVideoFullLight } from '@server/typings/models' | 66 | import { MVideoDetails, MVideoFullLight } from '@server/typings/models' |
68 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 67 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
69 | import { getVideoFilePath } from '@server/lib/video-paths' | 68 | import { getVideoFilePath } from '@server/lib/video-paths' |
70 | import toInt from 'validator/lib/toInt' | 69 | import toInt from 'validator/lib/toInt' |
70 | import { addOptimizeOrMergeAudioJob } from '@server/lib/videos' | ||
71 | 71 | ||
72 | const auditLogger = auditLoggerFactory('videos') | 72 | const auditLogger = auditLoggerFactory('videos') |
73 | const videosRouter = express.Router() | 73 | const videosRouter = express.Router() |
@@ -296,25 +296,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
296 | Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated) | 296 | Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated) |
297 | 297 | ||
298 | if (video.state === VideoState.TO_TRANSCODE) { | 298 | if (video.state === VideoState.TO_TRANSCODE) { |
299 | // Put uuid because we don't have id auto incremented for now | 299 | await addOptimizeOrMergeAudioJob(videoCreated, videoFile) |
300 | let dataInput: VideoTranscodingPayload | ||
301 | |||
302 | if (videoFile.isAudio()) { | ||
303 | dataInput = { | ||
304 | type: 'merge-audio' as 'merge-audio', | ||
305 | resolution: DEFAULT_AUDIO_RESOLUTION, | ||
306 | videoUUID: videoCreated.uuid, | ||
307 | isNewVideo: true | ||
308 | } | ||
309 | } else { | ||
310 | dataInput = { | ||
311 | type: 'optimize' as 'optimize', | ||
312 | videoUUID: videoCreated.uuid, | ||
313 | isNewVideo: true | ||
314 | } | ||
315 | } | ||
316 | |||
317 | await JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) | ||
318 | } | 300 | } |
319 | 301 | ||
320 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) | 302 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) |