aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/videos/common.ts
blob: 0431edaaf48e57b4bfe1c861169fe45020057098 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { VideoStreamingPlaylistType } from '@shared/models'
import { VideoPrivacy } from '../../models/videos/video-privacy.enum'
import { VideoDetails } from '../../models/videos/video.model'

function getAllPrivacies () {
  return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED, VideoPrivacy.PASSWORD_PROTECTED ]
}

function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) {
  const files = video.files

  const hls = getHLS(video)
  if (hls) return files.concat(hls.files)

  return files
}

function getHLS (video: Partial<Pick<VideoDetails, 'streamingPlaylists'>>) {
  return video.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
}

export {
  getAllPrivacies,
  getAllFiles,
  getHLS
}