video-captions.ts 711 B

12345678910111213141516171819202122232425
  1. import { Response } from 'express'
  2. import { VideoCaptionModel } from '@server/models/video/video-caption'
  3. import { MVideoId } from '@server/types/models'
  4. import { HttpStatusCode } from '@shared/models'
  5. async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
  6. const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
  7. if (!videoCaption) {
  8. res.fail({
  9. status: HttpStatusCode.NOT_FOUND_404,
  10. message: 'Video caption not found'
  11. })
  12. return false
  13. }
  14. res.locals.videoCaption = videoCaption
  15. return true
  16. }
  17. // ---------------------------------------------------------------------------
  18. export {
  19. doesVideoCaptionExist
  20. }