diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-15 14:08:16 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-02-16 10:36:44 +0100 |
commit | 6302d599cdf98b5a5363a2a1dcdc266447950191 (patch) | |
tree | b7dc6dc0f08f0fb8a20720242c9c0a71afeeaa3f /server/helpers | |
parent | a8b1b40485145ac1eae513a661d7dd6e0986ce96 (diff) | |
download | PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.gz PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.zst PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.zip |
Generate a name for caption files
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/captions-utils.ts | 12 | ||||
-rw-r--r-- | server/helpers/middlewares/video-captions.ts | 1 |
2 files changed, 6 insertions, 7 deletions
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 @@ | |||
1 | import { createReadStream, createWriteStream, move, remove } from 'fs-extra' | ||
1 | import { join } from 'path' | 2 | import { join } from 'path' |
2 | import { CONFIG } from '../initializers/config' | ||
3 | import * as srt2vtt from 'srt-to-vtt' | 3 | import * as srt2vtt from 'srt-to-vtt' |
4 | import { createReadStream, createWriteStream, move, remove } from 'fs-extra' | 4 | import { MVideoCaption } from '@server/types/models' |
5 | import { MVideoCaptionFormattable } from '@server/types/models' | 5 | import { CONFIG } from '../initializers/config' |
6 | 6 | ||
7 | async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaptionFormattable) { | 7 | async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) { |
8 | const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR | 8 | const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR |
9 | const destination = join(videoCaptionsDir, videoCaption.getCaptionName()) | 9 | const destination = join(videoCaptionsDir, videoCaption.filename) |
10 | 10 | ||
11 | // Convert this srt file to vtt | 11 | // Convert this srt file to vtt |
12 | if (physicalFile.path.endsWith('.srt')) { | 12 | if (physicalFile.path.endsWith('.srt')) { |
@@ -17,7 +17,7 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, path | |||
17 | } | 17 | } |
18 | 18 | ||
19 | // This is important in case if there is another attempt in the retry process | 19 | // This is important in case if there is another attempt in the retry process |
20 | physicalFile.filename = videoCaption.getCaptionName() | 20 | physicalFile.filename = videoCaption.filename |
21 | physicalFile.path = destination | 21 | physicalFile.path = destination |
22 | } | 22 | } |
23 | 23 | ||
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 | |||
9 | if (!videoCaption) { | 9 | if (!videoCaption) { |
10 | res.status(HttpStatusCode.NOT_FOUND_404) | 10 | res.status(HttpStatusCode.NOT_FOUND_404) |
11 | .json({ error: 'Video caption not found' }) | 11 | .json({ error: 'Video caption not found' }) |
12 | .end() | ||
13 | 12 | ||
14 | return false | 13 | return false |
15 | } | 14 | } |