1
0
Fork 0
peertube/shared/core-utils/videos/common.ts
2022-10-24 14:48:24 +02:00

26 lines
759 B
TypeScript

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 ]
}
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
}