]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/video.ts
Refractor videos AP functions
[github/Chocobozzz/PeerTube.git] / server / helpers / video.ts
CommitLineData
4157cdb1
C
1import { VideoModel } from '../models/video/video'
2
3type VideoFetchType = 'all' | 'only-video' | 'id' | 'none'
4
5function fetchVideo (id: number | string, fetchType: VideoFetchType) {
6 if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id)
7
8 if (fetchType === 'only-video') return VideoModel.load(id)
9
10 if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)
11}
12
13type VideoFetchByUrlType = 'all' | 'only-video'
14function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType) {
15 if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
16
17 if (fetchType === 'only-video') return VideoModel.loadByUrl(url)
18}
19
20export {
21 VideoFetchType,
22 VideoFetchByUrlType,
23 fetchVideo,
24 fetchVideoByUrl
25}