diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/import.ts | 22 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 6 |
2 files changed, 13 insertions, 15 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 28ced5836..ed223cbc9 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -88,12 +88,12 @@ async function addTorrentImport (req: express.Request, res: express.Response, to | |||
88 | const buf = await readFile(torrentfile.path) | 88 | const buf = await readFile(torrentfile.path) |
89 | const parsedTorrent = parseTorrent(buf) | 89 | const parsedTorrent = parseTorrent(buf) |
90 | 90 | ||
91 | videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[ 0 ] : parsedTorrent.name as string | 91 | videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[0] : parsedTorrent.name as string |
92 | } else { | 92 | } else { |
93 | magnetUri = body.magnetUri | 93 | magnetUri = body.magnetUri |
94 | 94 | ||
95 | const parsed = magnetUtil.decode(magnetUri) | 95 | const parsed = magnetUtil.decode(magnetUri) |
96 | videoName = isArray(parsed.name) ? parsed.name[ 0 ] : parsed.name as string | 96 | videoName = isArray(parsed.name) ? parsed.name[0] : parsed.name as string |
97 | } | 97 | } |
98 | 98 | ||
99 | const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }) | 99 | const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }) |
@@ -124,7 +124,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to | |||
124 | videoImportId: videoImport.id, | 124 | videoImportId: videoImport.id, |
125 | magnetUri | 125 | magnetUri |
126 | } | 126 | } |
127 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) | 127 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) |
128 | 128 | ||
129 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) | 129 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) |
130 | 130 | ||
@@ -176,7 +176,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
176 | downloadThumbnail: !thumbnailModel, | 176 | downloadThumbnail: !thumbnailModel, |
177 | downloadPreview: !previewModel | 177 | downloadPreview: !previewModel |
178 | } | 178 | } |
179 | await JobQueue.Instance.createJob({ type: 'video-import', payload }) | 179 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) |
180 | 180 | ||
181 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) | 181 | auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON())) |
182 | 182 | ||
@@ -211,7 +211,7 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You | |||
211 | async function processThumbnail (req: express.Request, video: VideoModel) { | 211 | async function processThumbnail (req: express.Request, video: VideoModel) { |
212 | const thumbnailField = req.files ? req.files['thumbnailfile'] : undefined | 212 | const thumbnailField = req.files ? req.files['thumbnailfile'] : undefined |
213 | if (thumbnailField) { | 213 | if (thumbnailField) { |
214 | const thumbnailPhysicalFile = thumbnailField[ 0 ] | 214 | const thumbnailPhysicalFile = thumbnailField[0] |
215 | 215 | ||
216 | return createVideoMiniatureFromExisting(thumbnailPhysicalFile.path, video, ThumbnailType.MINIATURE, false) | 216 | return createVideoMiniatureFromExisting(thumbnailPhysicalFile.path, video, ThumbnailType.MINIATURE, false) |
217 | } | 217 | } |
@@ -231,12 +231,12 @@ async function processPreview (req: express.Request, video: VideoModel) { | |||
231 | } | 231 | } |
232 | 232 | ||
233 | function insertIntoDB (parameters: { | 233 | function insertIntoDB (parameters: { |
234 | video: MVideoThumbnailAccountDefault, | 234 | video: MVideoThumbnailAccountDefault |
235 | thumbnailModel: MThumbnail, | 235 | thumbnailModel: MThumbnail |
236 | previewModel: MThumbnail, | 236 | previewModel: MThumbnail |
237 | videoChannel: MChannelAccountDefault, | 237 | videoChannel: MChannelAccountDefault |
238 | tags: string[], | 238 | tags: string[] |
239 | videoImportAttributes: Partial<MVideoImport>, | 239 | videoImportAttributes: Partial<MVideoImport> |
240 | user: MUser | 240 | user: MUser |
241 | }): Bluebird<MVideoImportFormattable> { | 241 | }): Bluebird<MVideoImportFormattable> { |
242 | const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters | 242 | const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index a593f7076..1d61f8427 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -12,8 +12,7 @@ import { | |||
12 | VIDEO_CATEGORIES, | 12 | VIDEO_CATEGORIES, |
13 | VIDEO_LANGUAGES, | 13 | VIDEO_LANGUAGES, |
14 | VIDEO_LICENCES, | 14 | VIDEO_LICENCES, |
15 | VIDEO_PRIVACIES, | 15 | VIDEO_PRIVACIES |
16 | VIDEO_TRANSCODING_FPS | ||
17 | } from '../../../initializers/constants' | 16 | } from '../../../initializers/constants' |
18 | import { | 17 | import { |
19 | changeVideoChannelShare, | 18 | changeVideoChannelShare, |
@@ -308,7 +307,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
308 | } | 307 | } |
309 | } | 308 | } |
310 | 309 | ||
311 | await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) | 310 | await JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) |
312 | } | 311 | } |
313 | 312 | ||
314 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) | 313 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) |
@@ -453,7 +452,6 @@ async function getVideo (req: express.Request, res: express.Response) { | |||
453 | 452 | ||
454 | if (video.isOutdated()) { | 453 | if (video.isOutdated()) { |
455 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } }) | 454 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } }) |
456 | .catch(err => logger.error('Cannot create AP refresher job for video %s.', video.url, { err })) | ||
457 | } | 455 | } |
458 | 456 | ||
459 | return res.json(video.toFormattedDetailsJSON()) | 457 | return res.json(video.toFormattedDetailsJSON()) |