aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/types/models/video/video-file.ts
blob: 55603e59c6671247d30b17871ce1818fd329d56a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                                
                                                                 
                                            
                                                                              
                                                                                        
 



                                                                               
                                                                                                      
 

                             
                      
 

                                         

                                                   

                                              

                                                        

                                 
                          
 

                                       

                                                                     

                                       
                                                                            







                                                                                          
import { PickWith, PickWithOpt } from '@shared/typescript-utils'
import { VideoFileModel } from '../../../models/video/video-file'
import { MVideo, MVideoUUID } from './video'
import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy'
import { MStreamingPlaylist, MStreamingPlaylistVideo } from './video-streaming-playlist'

type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>

// ############################################################################

export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos' | 'VideoStreamingPlaylist'>

export type MVideoFileVideo =
  MVideoFile &
  Use<'Video', MVideo>

export type MVideoFileStreamingPlaylist =
  MVideoFile &
  Use<'VideoStreamingPlaylist', MStreamingPlaylist>

export type MVideoFileStreamingPlaylistVideo =
  MVideoFile &
  Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>

export type MVideoFileVideoUUID =
  MVideoFile &
  Use<'Video', MVideoUUID>

export type MVideoFileRedundanciesAll =
  MVideoFile &
  PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancy[]>

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
}