From 6302d599cdf98b5a5363a2a1dcdc266447950191 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Feb 2021 14:08:16 +0100 Subject: Generate a name for caption files --- server/helpers/captions-utils.ts | 12 ++++++------ server/helpers/middlewares/video-captions.ts | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts index 7cbfb3561..401f2fb7b 100644 --- a/server/helpers/captions-utils.ts +++ b/server/helpers/captions-utils.ts @@ -1,12 +1,12 @@ +import { createReadStream, createWriteStream, move, remove } from 'fs-extra' import { join } from 'path' -import { CONFIG } from '../initializers/config' import * as srt2vtt from 'srt-to-vtt' -import { createReadStream, createWriteStream, move, remove } from 'fs-extra' -import { MVideoCaptionFormattable } from '@server/types/models' +import { MVideoCaption } from '@server/types/models' +import { CONFIG } from '../initializers/config' -async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaptionFormattable) { +async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) { const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR - const destination = join(videoCaptionsDir, videoCaption.getCaptionName()) + const destination = join(videoCaptionsDir, videoCaption.filename) // Convert this srt file to vtt if (physicalFile.path.endsWith('.srt')) { @@ -17,7 +17,7 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, path } // This is important in case if there is another attempt in the retry process - physicalFile.filename = videoCaption.getCaptionName() + physicalFile.filename = videoCaption.filename physicalFile.path = destination } diff --git a/server/helpers/middlewares/video-captions.ts b/server/helpers/middlewares/video-captions.ts index 10267eda1..226d3c5f8 100644 --- a/server/helpers/middlewares/video-captions.ts +++ b/server/helpers/middlewares/video-captions.ts @@ -9,7 +9,6 @@ async function doesVideoCaptionExist (video: MVideoId, language: string, res: Re if (!videoCaption) { res.status(HttpStatusCode.NOT_FOUND_404) .json({ error: 'Video caption not found' }) - .end() return false } -- cgit v1.2.3