]>
Commit | Line | Data |
---|---|---|
4157cdb1 C |
1 | import { VideoModel } from '../models/video/video' |
2 | ||
09209296 | 3 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' |
4157cdb1 | 4 | |
6e46de09 C |
5 | function fetchVideo (id: number | string, fetchType: VideoFetchType, userId?: number) { |
6 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) | |
4157cdb1 | 7 | |
09209296 C |
8 | if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id) |
9 | ||
4157cdb1 C |
10 | if (fetchType === 'only-video') return VideoModel.load(id) |
11 | ||
12 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) | |
13 | } | |
14 | ||
15 | type VideoFetchByUrlType = 'all' | 'only-video' | |
16 | function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType) { | |
17 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) | |
18 | ||
19 | if (fetchType === 'only-video') return VideoModel.loadByUrl(url) | |
20 | } | |
21 | ||
22 | export { | |
23 | VideoFetchType, | |
24 | VideoFetchByUrlType, | |
25 | fetchVideo, | |
26 | fetchVideoByUrl | |
27 | } |