diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/captions.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 11 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 12 |
3 files changed, 9 insertions, 18 deletions
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 3ba918189..9b3661368 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' | 2 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' |
3 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' | 3 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' |
4 | import { createReqFiles } from '../../../helpers/express-utils' | 4 | import { createReqFiles } from '../../../helpers/express-utils' |
5 | import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' | 5 | import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
7 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 7 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
8 | import { VideoModel } from '../../../models/video/video' | 8 | import { VideoModel } from '../../../models/video/video' |
@@ -12,7 +12,7 @@ import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | |||
12 | 12 | ||
13 | const reqVideoCaptionAdd = createReqFiles( | 13 | const reqVideoCaptionAdd = createReqFiles( |
14 | [ 'captionfile' ], | 14 | [ 'captionfile' ], |
15 | VIDEO_CAPTIONS_MIMETYPE_EXT, | 15 | MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT, |
16 | { | 16 | { |
17 | captionfile: CONFIG.STORAGE.CAPTIONS_DIR | 17 | captionfile: CONFIG.STORAGE.CAPTIONS_DIR |
18 | } | 18 | } |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index f27d648c7..099ab7b8d 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -3,14 +3,7 @@ import * as magnetUtil from 'magnet-uri' | |||
3 | import 'multer' | 3 | import 'multer' |
4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' | 4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' | 5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' |
6 | import { | 6 | import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' |
7 | CONFIG, | ||
8 | IMAGE_MIMETYPE_EXT, | ||
9 | PREVIEWS_SIZE, | ||
10 | sequelizeTypescript, | ||
11 | THUMBNAILS_SIZE, | ||
12 | TORRENT_MIMETYPE_EXT | ||
13 | } from '../../../initializers' | ||
14 | import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' | 7 | import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' |
15 | import { createReqFiles } from '../../../helpers/express-utils' | 8 | import { createReqFiles } from '../../../helpers/express-utils' |
16 | import { logger } from '../../../helpers/logger' | 9 | import { logger } from '../../../helpers/logger' |
@@ -35,7 +28,7 @@ const videoImportsRouter = express.Router() | |||
35 | 28 | ||
36 | const reqVideoFileImport = createReqFiles( | 29 | const reqVideoFileImport = createReqFiles( |
37 | [ 'thumbnailfile', 'previewfile', 'torrentfile' ], | 30 | [ 'thumbnailfile', 'previewfile', 'torrentfile' ], |
38 | Object.assign({}, TORRENT_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), | 31 | Object.assign({}, MIMETYPES.TORRENT.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT), |
39 | { | 32 | { |
40 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | 33 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, |
41 | previewfile: CONFIG.STORAGE.TMP_DIR, | 34 | previewfile: CONFIG.STORAGE.TMP_DIR, |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 4e4697ef4..00a1302d1 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -7,15 +7,13 @@ import { logger } from '../../../helpers/logger' | |||
7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
9 | import { | 9 | import { |
10 | CONFIG, | 10 | CONFIG, MIMETYPES, |
11 | IMAGE_MIMETYPE_EXT, | ||
12 | PREVIEWS_SIZE, | 11 | PREVIEWS_SIZE, |
13 | sequelizeTypescript, | 12 | sequelizeTypescript, |
14 | THUMBNAILS_SIZE, | 13 | THUMBNAILS_SIZE, |
15 | VIDEO_CATEGORIES, | 14 | VIDEO_CATEGORIES, |
16 | VIDEO_LANGUAGES, | 15 | VIDEO_LANGUAGES, |
17 | VIDEO_LICENCES, | 16 | VIDEO_LICENCES, |
18 | VIDEO_MIMETYPE_EXT, | ||
19 | VIDEO_PRIVACIES | 17 | VIDEO_PRIVACIES |
20 | } from '../../../initializers' | 18 | } from '../../../initializers' |
21 | import { | 19 | import { |
@@ -57,7 +55,7 @@ import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-u | |||
57 | import { videoCaptionsRouter } from './captions' | 55 | import { videoCaptionsRouter } from './captions' |
58 | import { videoImportsRouter } from './import' | 56 | import { videoImportsRouter } from './import' |
59 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | 57 | import { resetSequelizeInstance } from '../../../helpers/database-utils' |
60 | import { rename } from 'fs-extra' | 58 | import { move } from 'fs-extra' |
61 | import { watchingRouter } from './watching' | 59 | import { watchingRouter } from './watching' |
62 | 60 | ||
63 | const auditLogger = auditLoggerFactory('videos') | 61 | const auditLogger = auditLoggerFactory('videos') |
@@ -65,7 +63,7 @@ const videosRouter = express.Router() | |||
65 | 63 | ||
66 | const reqVideoFileAdd = createReqFiles( | 64 | const reqVideoFileAdd = createReqFiles( |
67 | [ 'videofile', 'thumbnailfile', 'previewfile' ], | 65 | [ 'videofile', 'thumbnailfile', 'previewfile' ], |
68 | Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), | 66 | Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT), |
69 | { | 67 | { |
70 | videofile: CONFIG.STORAGE.TMP_DIR, | 68 | videofile: CONFIG.STORAGE.TMP_DIR, |
71 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | 69 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, |
@@ -74,7 +72,7 @@ const reqVideoFileAdd = createReqFiles( | |||
74 | ) | 72 | ) |
75 | const reqVideoFileUpdate = createReqFiles( | 73 | const reqVideoFileUpdate = createReqFiles( |
76 | [ 'thumbnailfile', 'previewfile' ], | 74 | [ 'thumbnailfile', 'previewfile' ], |
77 | IMAGE_MIMETYPE_EXT, | 75 | MIMETYPES.IMAGE.MIMETYPE_EXT, |
78 | { | 76 | { |
79 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, | 77 | thumbnailfile: CONFIG.STORAGE.TMP_DIR, |
80 | previewfile: CONFIG.STORAGE.TMP_DIR | 78 | previewfile: CONFIG.STORAGE.TMP_DIR |
@@ -208,7 +206,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
208 | // Move physical file | 206 | // Move physical file |
209 | const videoDir = CONFIG.STORAGE.VIDEOS_DIR | 207 | const videoDir = CONFIG.STORAGE.VIDEOS_DIR |
210 | const destination = join(videoDir, video.getVideoFilename(videoFile)) | 208 | const destination = join(videoDir, video.getVideoFilename(videoFile)) |
211 | await rename(videoPhysicalFile.path, destination) | 209 | await move(videoPhysicalFile.path, destination) |
212 | // This is important in case if there is another attempt in the retry process | 210 | // This is important in case if there is another attempt in the retry process |
213 | videoPhysicalFile.filename = video.getVideoFilename(videoFile) | 211 | videoPhysicalFile.filename = video.getVideoFilename(videoFile) |
214 | videoPhysicalFile.path = destination | 212 | videoPhysicalFile.path = destination |