PeerTube/server/typings/models/video/video-file.ts

35 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-08-15 04:53:26 -05:00
import { VideoFileModel } from '../../../models/video/video-file'
import { PickWith, PickWithOpt } from '../../utils'
import { MVideo, MVideoUUID } from './video'
import { MVideoRedundancyFileUrl } from './video-redundancy'
import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist'
2019-08-15 04:53:26 -05:00
2019-08-20 06:52:49 -05:00
type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
// ############################################################################
export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos' | 'VideoStreamingPlaylist'>
2019-08-15 04:53:26 -05:00
export type MVideoFileVideo = MVideoFile &
2019-08-20 06:52:49 -05:00
Use<'Video', MVideo>
2019-08-15 04:53:26 -05:00
export type MVideoFileStreamingPlaylist = MVideoFile &
Use<'VideoStreamingPlaylist', MStreamingPlaylist>
export type MVideoFileStreamingPlaylistVideo = MVideoFile &
Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
2019-08-15 04:53:26 -05:00
export type MVideoFileVideoUUID = MVideoFile &
2019-08-20 06:52:49 -05:00
Use<'Video', MVideoUUID>
2019-08-15 04:53:26 -05:00
export type MVideoFileRedundanciesOpt = MVideoFile &
PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
export function isStreamingPlaylistFile (file: any): file is MVideoFileStreamingPlaylist {
return !!file.videoStreamingPlaylistId
}
export function isWebtorrentFile (file: any): file is MVideoFileVideo {
return !!file.videoId
}