diff options
Diffstat (limited to 'server/controllers/api/runners/jobs-files.ts')
-rw-r--r-- | server/controllers/api/runners/jobs-files.ts | 112 |
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 @@ | |||
1 | import express from 'express' | ||
2 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | ||
3 | import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage' | ||
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | ||
5 | import { getStudioTaskFilePath } from '@server/lib/video-studio' | ||
6 | import { apiRateLimiter, asyncMiddleware } from '@server/middlewares' | ||
7 | import { jobOfRunnerGetValidatorFactory } from '@server/middlewares/validators/runners' | ||
8 | import { | ||
9 | runnerJobGetVideoStudioTaskFileValidator, | ||
10 | runnerJobGetVideoTranscodingFileValidator | ||
11 | } from '@server/middlewares/validators/runners/job-files' | ||
12 | import { RunnerJobState, VideoStorage } from '@shared/models' | ||
13 | |||
14 | const lTags = loggerTagsFactory('api', 'runner') | ||
15 | |||
16 | const runnerJobFilesRouter = express.Router() | ||
17 | |||
18 | runnerJobFilesRouter.post('/jobs/:jobUUID/files/videos/:videoId/max-quality', | ||
19 | apiRateLimiter, | ||
20 | asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])), | ||
21 | asyncMiddleware(runnerJobGetVideoTranscodingFileValidator), | ||
22 | asyncMiddleware(getMaxQualityVideoFile) | ||
23 | ) | ||
24 | |||
25 | runnerJobFilesRouter.post('/jobs/:jobUUID/files/videos/:videoId/previews/max-quality', | ||
26 | apiRateLimiter, | ||
27 | asyncMiddleware(jobOfRunnerGetValidatorFactory([ RunnerJobState.PROCESSING ])), | ||
28 | asyncMiddleware(runnerJobGetVideoTranscodingFileValidator), | ||
29 | getMaxQualityVideoPreview | ||
30 | ) | ||
31 | |||
32 | runnerJobFilesRouter.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 | |||
42 | export { | ||
43 | runnerJobFilesRouter | ||
44 | } | ||
45 | |||
46 | // --------------------------------------------------------------------------- | ||
47 | |||
48 | async 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 | |||
85 | function 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 | |||
100 | function 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 | } | ||