aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/lazy-static.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-15 14:08:16 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-16 10:36:44 +0100
commit6302d599cdf98b5a5363a2a1dcdc266447950191 (patch)
treeb7dc6dc0f08f0fb8a20720242c9c0a71afeeaa3f /server/controllers/lazy-static.ts
parenta8b1b40485145ac1eae513a661d7dd6e0986ce96 (diff)
downloadPeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.gz
PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.tar.zst
PeerTube-6302d599cdf98b5a5363a2a1dcdc266447950191.zip
Generate a name for caption files
Diffstat (limited to 'server/controllers/lazy-static.ts')
-rw-r--r--server/controllers/lazy-static.ts7
1 files changed, 2 insertions, 5 deletions
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 847d24fd4..656dea223 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -23,7 +23,7 @@ lazyStaticRouter.use(
23) 23)
24 24
25lazyStaticRouter.use( 25lazyStaticRouter.use(
26 LAZY_STATIC_PATHS.VIDEO_CAPTIONS + ':videoId-:captionLanguage([a-z]+).vtt', 26 LAZY_STATIC_PATHS.VIDEO_CAPTIONS + ':filename',
27 asyncMiddleware(getVideoCaption) 27 asyncMiddleware(getVideoCaption)
28) 28)
29 29
@@ -78,10 +78,7 @@ async function getPreview (req: express.Request, res: express.Response) {
78} 78}
79 79
80async function getVideoCaption (req: express.Request, res: express.Response) { 80async function getVideoCaption (req: express.Request, res: express.Response) {
81 const result = await VideosCaptionCache.Instance.getFilePath({ 81 const result = await VideosCaptionCache.Instance.getFilePath(req.params.filename)
82 videoId: req.params.videoId,
83 language: req.params.captionLanguage
84 })
85 if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) 82 if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
86 83
87 return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER }) 84 return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER })