diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-20 16:24:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 16:24:31 +0200 |
commit | 0491173a61aed66205c017e0d7e0503ea316c144 (patch) | |
tree | ce6621597505f9518cfdf0981977d097c63f9fad /server/helpers/video.ts | |
parent | 8704acf49efc770d73bf07c10468ed8c74d28a83 (diff) | |
parent | 6247b2057b792cea155a1abd9788c363ae7d2cc2 (diff) | |
download | PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.tar.gz PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.tar.zst PeerTube-0491173a61aed66205c017e0d7e0503ea316c144.zip |
Merge branch 'develop' into cli-wrapper
Diffstat (limited to 'server/helpers/video.ts')
-rw-r--r-- | server/helpers/video.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/helpers/video.ts b/server/helpers/video.ts new file mode 100644 index 000000000..b1577a6b0 --- /dev/null +++ b/server/helpers/video.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { VideoModel } from '../models/video/video' | ||
2 | |||
3 | type VideoFetchType = 'all' | 'only-video' | 'id' | 'none' | ||
4 | |||
5 | function 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 | |||
13 | type VideoFetchByUrlType = 'all' | 'only-video' | ||
14 | function 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 | |||
20 | export { | ||
21 | VideoFetchType, | ||
22 | VideoFetchByUrlType, | ||
23 | fetchVideo, | ||
24 | fetchVideoByUrl | ||
25 | } | ||