From f4001cf408a99049d01a356bfb20a62342de06ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Jul 2018 14:22:16 +0200 Subject: Handle .srt subtitles --- server/controllers/api/videos/captions.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 05412a17f..4cf8de1ef 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts @@ -9,11 +9,10 @@ import { createReqFiles } from '../../../helpers/express-utils' import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' import { getFormattedObjects } from '../../../helpers/utils' import { VideoCaptionModel } from '../../../models/video/video-caption' -import { renamePromise } from '../../../helpers/core-utils' -import { join } from 'path' import { VideoModel } from '../../../models/video/video' import { logger } from '../../../helpers/logger' import { federateVideoIfNeeded } from '../../../lib/activitypub' +import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' const reqVideoCaptionAdd = createReqFiles( [ 'captionfile' ], @@ -66,12 +65,7 @@ async function addVideoCaption (req: express.Request, res: express.Response) { videoCaption.Video = video // Move physical file - const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR - const destination = join(videoCaptionsDir, videoCaption.getCaptionName()) - await renamePromise(videoCaptionPhysicalFile.path, destination) - // This is important in case if there is another attempt in the retry process - videoCaptionPhysicalFile.filename = videoCaption.getCaptionName() - videoCaptionPhysicalFile.path = destination + await moveAndProcessCaptionFile(videoCaptionPhysicalFile, videoCaption) await sequelizeTypescript.transaction(async t => { await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t) -- cgit v1.2.3