1 import { VideoModel } from '@server/models/video/video'
3 MVideoAccountLightBlacklistAllFiles,
9 } from '@server/types/models'
11 type VideoLoadType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
13 function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>
14 function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
15 function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
16 function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights>
17 function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail>
20 fetchType: VideoLoadType,
22 ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable>
25 fetchType: VideoLoadType,
27 ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> {
28 if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
30 if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
32 if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
34 if (fetchType === 'only-video') return VideoModel.load(id)
36 if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)
39 type VideoLoadByUrlType = 'all' | 'only-video' | 'only-immutable-attributes'
41 function loadVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles>
42 function loadVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
43 function loadVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail>
44 function loadVideoByUrl (
46 fetchType: VideoLoadByUrlType
47 ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable>
48 function loadVideoByUrl (
50 fetchType: VideoLoadByUrlType
51 ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> {
52 if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
54 if (fetchType === 'only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url)
56 if (fetchType === 'only-video') return VideoModel.loadByUrl(url)