aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-studio/shared/video-studio.service.ts
blob: a3aabd347c5e0de60086f2832c53a5f21bae6391 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { catchError } from 'rxjs'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { RestExtractor } from '@app/core'
import { objectToFormData } from '@app/helpers'
import { VideoService } from '@app/shared/shared-main'
import { VideoStudioCreateEdition, VideoStudioTask } from '@peertube/peertube-models'

@Injectable()
export class VideoStudioService {

  constructor (
    private authHttp: HttpClient,
    private restExtractor: RestExtractor
  ) {}

  editVideo (videoId: number | string, tasks: VideoStudioTask[]) {
    const url = VideoService.BASE_VIDEO_URL + '/' + videoId + '/studio/edit'
    const body: VideoStudioCreateEdition = {
      tasks
    }

    const data = objectToFormData(body)

    return this.authHttp.post(url, data)
      .pipe(catchError(err => this.restExtractor.handleError(err)))
  }
}