diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:22:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:31:40 +0200 |
commit | f4001cf408a99049d01a356bfb20a62342de06ea (patch) | |
tree | 421776dfe64335dca2725ac3ac5f3b3e6b7564c6 /server/controllers/api/videos/captions.ts | |
parent | 16f7022b06fb76c0b00c23c970bc8df605b0ec63 (diff) | |
download | PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.gz PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.zst PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.zip |
Handle .srt subtitles
Diffstat (limited to 'server/controllers/api/videos/captions.ts')
-rw-r--r-- | server/controllers/api/videos/captions.ts | 10 |
1 files changed, 2 insertions, 8 deletions
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' | |||
9 | import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' | 9 | import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' |
10 | import { getFormattedObjects } from '../../../helpers/utils' | 10 | import { getFormattedObjects } from '../../../helpers/utils' |
11 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 11 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
12 | import { renamePromise } from '../../../helpers/core-utils' | ||
13 | import { join } from 'path' | ||
14 | import { VideoModel } from '../../../models/video/video' | 12 | import { VideoModel } from '../../../models/video/video' |
15 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
16 | import { federateVideoIfNeeded } from '../../../lib/activitypub' | 14 | import { federateVideoIfNeeded } from '../../../lib/activitypub' |
15 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | ||
17 | 16 | ||
18 | const reqVideoCaptionAdd = createReqFiles( | 17 | const reqVideoCaptionAdd = createReqFiles( |
19 | [ 'captionfile' ], | 18 | [ 'captionfile' ], |
@@ -66,12 +65,7 @@ async function addVideoCaption (req: express.Request, res: express.Response) { | |||
66 | videoCaption.Video = video | 65 | videoCaption.Video = video |
67 | 66 | ||
68 | // Move physical file | 67 | // Move physical file |
69 | const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR | 68 | await moveAndProcessCaptionFile(videoCaptionPhysicalFile, videoCaption) |
70 | const destination = join(videoCaptionsDir, videoCaption.getCaptionName()) | ||
71 | await renamePromise(videoCaptionPhysicalFile.path, destination) | ||
72 | // This is important in case if there is another attempt in the retry process | ||
73 | videoCaptionPhysicalFile.filename = videoCaption.getCaptionName() | ||
74 | videoCaptionPhysicalFile.path = destination | ||
75 | 69 | ||
76 | await sequelizeTypescript.transaction(async t => { | 70 | await sequelizeTypescript.transaction(async t => { |
77 | await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t) | 71 | await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t) |