diff options
Diffstat (limited to 'server/controllers/api/videos/import.ts')
-rw-r--r-- | server/controllers/api/videos/import.ts | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 0d5d7a962..6ee109a8f 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -18,7 +18,6 @@ import { | |||
18 | } from '@server/types/models' | 18 | } from '@server/types/models' |
19 | import { MVideoImportFormattable } from '@server/types/models/video/video-import' | 19 | import { MVideoImportFormattable } from '@server/types/models/video/video-import' |
20 | import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared' | 20 | import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared' |
21 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
22 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 21 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
23 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' | 22 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
24 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 23 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
@@ -143,10 +142,12 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
143 | } catch (err) { | 142 | } catch (err) { |
144 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) | 143 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) |
145 | 144 | ||
146 | return res.status(HttpStatusCode.BAD_REQUEST_400) | 145 | return res.fail({ |
147 | .json({ | 146 | message: 'Cannot fetch remote information of this URL.', |
148 | error: 'Cannot fetch remote information of this URL.' | 147 | data: { |
149 | }) | 148 | targetUrl |
149 | } | ||
150 | }) | ||
150 | } | 151 | } |
151 | 152 | ||
152 | const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) | 153 | const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) |
@@ -333,12 +334,10 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express. | |||
333 | if (parsedTorrent.files.length !== 1) { | 334 | if (parsedTorrent.files.length !== 1) { |
334 | cleanUpReqFiles(req) | 335 | cleanUpReqFiles(req) |
335 | 336 | ||
336 | res.status(HttpStatusCode.BAD_REQUEST_400) | 337 | res.fail({ |
337 | .json({ | 338 | type: ServerErrorCode.INCORRECT_FILES_IN_TORRENT.toString(), |
338 | code: ServerErrorCode.INCORRECT_FILES_IN_TORRENT, | 339 | message: 'Torrents with only 1 file are supported.' |
339 | error: 'Torrents with only 1 file are supported.' | 340 | }) |
340 | }) | ||
341 | |||
342 | return undefined | 341 | return undefined |
343 | } | 342 | } |
344 | 343 | ||