aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/shared/video-fetcher.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone/videos/shared/video-fetcher.ts')
-rw-r--r--client/src/standalone/videos/shared/video-fetcher.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/client/src/standalone/videos/shared/video-fetcher.ts b/client/src/standalone/videos/shared/video-fetcher.ts
index b42d622f9..cf6d12831 100644
--- a/client/src/standalone/videos/shared/video-fetcher.ts
+++ b/client/src/standalone/videos/shared/video-fetcher.ts
@@ -1,4 +1,4 @@
1import { HttpStatusCode, LiveVideo, VideoDetails } from '../../../../../shared/models' 1import { HttpStatusCode, LiveVideo, VideoDetails, VideoToken } from '../../../../../shared/models'
2import { logger } from '../../../root-helpers' 2import { logger } from '../../../root-helpers'
3import { AuthHTTP } from './auth-http' 3import { AuthHTTP } from './auth-http'
4 4
@@ -36,10 +36,15 @@ export class VideoFetcher {
36 return { captionsPromise, videoResponse } 36 return { captionsPromise, videoResponse }
37 } 37 }
38 38
39 loadVideoWithLive (video: VideoDetails) { 39 loadLive (video: VideoDetails) {
40 return this.http.fetch(this.getLiveUrl(video.uuid), { optionalAuth: true }) 40 return this.http.fetch(this.getLiveUrl(video.uuid), { optionalAuth: true })
41 .then(res => res.json()) 41 .then(res => res.json() as Promise<LiveVideo>)
42 .then((live: LiveVideo) => ({ video, live })) 42 }
43
44 loadVideoToken (video: VideoDetails) {
45 return this.http.fetch(this.getVideoTokenUrl(video.uuid), { optionalAuth: true, method: 'POST' })
46 .then(res => res.json() as Promise<VideoToken>)
47 .then(token => token.files.token)
43 } 48 }
44 49
45 getVideoViewsUrl (videoUUID: string) { 50 getVideoViewsUrl (videoUUID: string) {
@@ -61,4 +66,8 @@ export class VideoFetcher {
61 private getLiveUrl (videoId: string) { 66 private getLiveUrl (videoId: string) {
62 return window.location.origin + '/api/v1/videos/live/' + videoId 67 return window.location.origin + '/api/v1/videos/live/' + videoId
63 } 68 }
69
70 private getVideoTokenUrl (id: string) {
71 return this.getVideoUrl(id) + '/token'
72 }
64} 73}