1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Add storyboard support

This commit is contained in:
Chocobozzz 2023-06-01 14:51:16 +02:00
parent 1fb7d09422
commit d8f39b126d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
79 changed files with 1476 additions and 100 deletions

View file

@ -5,7 +5,7 @@ import { MActorImage } from '@server/types/models'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
import { ACTOR_IMAGES_SIZE, LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants'
import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache'
import { VideosCaptionCache, VideosPreviewCache, VideosStoryboardCache } from '../lib/files-cache'
import { actorImagePathUnsafeCache, downloadActorImageFromWorker } from '../lib/local-actor'
import { asyncMiddleware, handleStaticError } from '../middlewares'
import { ActorImageModel } from '../models/actor/actor-image'
@ -32,6 +32,12 @@ lazyStaticRouter.use(
handleStaticError
)
lazyStaticRouter.use(
LAZY_STATIC_PATHS.STORYBOARDS + ':filename',
asyncMiddleware(getStoryboard),
handleStaticError
)
lazyStaticRouter.use(
LAZY_STATIC_PATHS.VIDEO_CAPTIONS + ':filename',
asyncMiddleware(getVideoCaption),
@ -126,6 +132,13 @@ async function getPreview (req: express.Request, res: express.Response) {
return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
}
async function getStoryboard (req: express.Request, res: express.Response) {
const result = await VideosStoryboardCache.Instance.getFilePath(req.params.filename)
if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
}
async function getVideoCaption (req: express.Request, res: express.Response) {
const result = await VideosCaptionCache.Instance.getFilePath(req.params.filename)
if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()