aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/runners/jobs-files.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/runners/jobs-files.ts')
-rw-r--r--server/controllers/api/runners/jobs-files.ts112
1 files changed, 0 insertions, 112 deletions
diff --git a/server/controllers/api/runners/jobs-files.ts b/server/controllers/api/runners/jobs-files.ts
deleted file mode 100644
index d28f43701..000000000
--- a/server/controllers/api/runners/jobs-files.ts
+++ /dev/null
@@ -1,112 +0,0 @@
1import express from 'express'
2import { logger, loggerTagsFactory } from '@server/helpers/logger'
3import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage'
4import { VideoPathManager } from '@server/lib/video-path-manager'
5import { getStudioTaskFilePath } from '@server/lib/video-studio'
6import { apiRateLimiter, asyncMiddleware } from '@server/middlewares'
7import { jobOfRunnerGetValidatorFactory } from '@server/middlewares/validators/runners'
8import {
9 runnerJobGetVideoStudioTaskFileValidator,
10 runnerJobGetVideoTranscodingFileValidator
11} from '@server/middlewares/validators/runners/job-files'
12import { RunnerJobState, VideoStorage } from '@shared/models'
13
14const lTags = loggerTagsFactory('api', 'runner')
15
16const runnerJobFilesRouter = express.Router()
17
18runnerJobFilesRouter.post('/jobs/:jobUUID/files/videos/:videoId/max-quality',
19 apiRateLimiter,
20 asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
21 asyncMiddleware(runnerJobGetVideoTranscodingFileValidator),
22 asyncMiddleware(getMaxQualityVideoFile)
23)
24
25runnerJobFilesRouter.post('/jobs/:jobUUID/files/videos/:videoId/previews/max-quality',
26 apiRateLimiter,
27 asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
28 asyncMiddleware(runnerJobGetVideoTranscodingFileValidator),
29 getMaxQualityVideoPreview
30)
31
32runnerJobFilesRouter.post('/jobs/:jobUUID/files/videos/:videoId/studio/task-files/:filename',
33 apiRateLimiter,
34 asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])),
35 asyncMiddleware(runnerJobGetVideoTranscodingFileValidator),
36 runnerJobGetVideoStudioTaskFileValidator,
37 getVideoStudioTaskFile
38)
39
40// ---------------------------------------------------------------------------
41
42export {
43 runnerJobFilesRouter
44}
45
46// ---------------------------------------------------------------------------
47
48async function getMaxQualityVideoFile (req: express.Request, res: express.Response) {
49 const runnerJob = res.locals.runnerJob
50 const runner = runnerJob.Runner
51 const video = res.locals.videoAll
52
53 logger.info(
54 'Get max quality file of video %s of job %s for runner %s', video.uuid, runnerJob.uuid, runner.name,
55 lTags(runner.name, runnerJob.id, runnerJob.type)
56 )
57
58 const file = video.getMaxQualityFile()
59
60 if (file.storage === VideoStorage.OBJECT_STORAGE) {
61 if (file.isHLS()) {
62 return proxifyHLS({
63 req,
64 res,
65 filename: file.filename,
66 playlist: video.getHLSPlaylist(),
67 reinjectVideoFileToken: false,
68 video
69 })
70 }
71
72 // Web video
73 return proxifyWebVideoFile({
74 req,
75 res,
76 filename: file.filename
77 })
78 }
79
80 return VideoPathManager.Instance.makeAvailableVideoFile(file, videoPath => {
81 return res.sendFile(videoPath)
82 })
83}
84
85function getMaxQualityVideoPreview (req: express.Request, res: express.Response) {
86 const runnerJob = res.locals.runnerJob
87 const runner = runnerJob.Runner
88 const video = res.locals.videoAll
89
90 logger.info(
91 'Get max quality preview file of video %s of job %s for runner %s', video.uuid, runnerJob.uuid, runner.name,
92 lTags(runner.name, runnerJob.id, runnerJob.type)
93 )
94
95 const file = video.getPreview()
96
97 return res.sendFile(file.getPath())
98}
99
100function getVideoStudioTaskFile (req: express.Request, res: express.Response) {
101 const runnerJob = res.locals.runnerJob
102 const runner = runnerJob.Runner
103 const video = res.locals.videoAll
104 const filename = req.params.filename
105
106 logger.info(
107 'Get video studio task file %s of video %s of job %s for runner %s', filename, video.uuid, runnerJob.uuid, runner.name,
108 lTags(runner.name, runnerJob.id, runnerJob.type)
109 )
110
111 return res.sendFile(getStudioTaskFilePath(filename))
112}