]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-video-live/live-video.service.ts
Fix comment add avatar when unlogged
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-live / live-video.service.ts
CommitLineData
c6c0fa6c
C
1import { catchError } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { RestExtractor } from '@app/core'
39e68a32 5import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models'
f8c00564 6import { environment } from '../../../environments/environment'
f40712ab 7import { VideoService } from '../shared-main'
c6c0fa6c
C
8
9@Injectable()
a5cf76af 10export class LiveVideoService {
c6c0fa6c
C
11 static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/'
12
13 constructor (
14 private authHttp: HttpClient,
15 private restExtractor: RestExtractor
16 ) {}
17
b5b68755 18 goLive (video: LiveVideoCreate) {
c6c0fa6c 19 return this.authHttp
2e80d256 20 .post<{ video: VideoCreateResult }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video)
c6c0fa6c
C
21 .pipe(catchError(err => this.restExtractor.handleError(err)))
22 }
23
24 getVideoLive (videoId: number | string) {
25 return this.authHttp
a5cf76af 26 .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId)
c6c0fa6c
C
27 .pipe(catchError(err => this.restExtractor.handleError(err)))
28 }
b5b68755 29
39e68a32
C
30 listSessions (videoId: number | string) {
31 return this.authHttp
32 .get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions')
33 .pipe(catchError(err => this.restExtractor.handleError(err)))
34 }
35
f40712ab
C
36 findLiveSessionFromVOD (videoId: number | string) {
37 return this.authHttp
38 .get<LiveVideoSession>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/live-session')
39 .pipe(catchError(err => this.restExtractor.handleError(err)))
40 }
41
b5b68755
C
42 updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) {
43 return this.authHttp
44 .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate)
45 .pipe(catchError(err => this.restExtractor.handleError(err)))
46 }
c6c0fa6c 47}