video-file.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { VideoFileModel } from '../../../models/video/video-file'
  2. import { PickWith, PickWithOpt } from '../../utils'
  3. import { MVideo, MVideoUUID } from './video'
  4. import { MVideoRedundancyFileUrl } from './video-redundancy'
  5. import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist'
  6. type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
  7. // ############################################################################
  8. export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos' | 'VideoStreamingPlaylist'>
  9. export type MVideoFileVideo = MVideoFile &
  10. Use<'Video', MVideo>
  11. export type MVideoFileStreamingPlaylist = MVideoFile &
  12. Use<'VideoStreamingPlaylist', MStreamingPlaylist>
  13. export type MVideoFileStreamingPlaylistVideo = MVideoFile &
  14. Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
  15. export type MVideoFileVideoUUID = MVideoFile &
  16. Use<'Video', MVideoUUID>
  17. export type MVideoFileRedundanciesOpt = MVideoFile &
  18. PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
  19. export function isStreamingPlaylistFile (file: any): file is MVideoFileStreamingPlaylist {
  20. return !!file.videoStreamingPlaylistId
  21. }
  22. export function isWebtorrentFile (file: any): file is MVideoFileVideo {
  23. return !!file.videoId
  24. }