import { SortMeta } from 'primeng/api'
-import { from, Observable } from 'rxjs'
+import { from, Observable, of } from 'rxjs'
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
VideoTranscodingCreate,
VideoUpdate
} from '@shared/models'
+import { VideoSource } from '@shared/models/videos/video-source'
import { environment } from '../../../../environments/environment'
import { Account } from '../account/account.model'
import { AccountService } from '../account/account.service'
)
}
- setVideoLike (id: number) {
+ getSource (videoId: number) {
+ return this.authHttp
+ .get<{ source: VideoSource }>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/source')
+ .pipe(
+ catchError(err => {
+ if (err.status === 404) {
+ return of(undefined)
+ }
+
+ this.restExtractor.handleError(err)
+ })
+ )
+ }
+
+ setVideoLike (id: string) {
return this.setVideoRate(id, 'like')
}
- setVideoDislike (id: number) {
+ setVideoDislike (id: string) {
return this.setVideoRate(id, 'dislike')
}
- unsetVideoLike (id: number) {
+ unsetVideoLike (id: string) {
return this.setVideoRate(id, 'none')
}
- getUserVideoRating (id: number) {
+ getUserVideoRating (id: string) {
const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'
return this.authHttp.get<UserVideoRate>(url)
}
}
- private setVideoRate (id: number, rateType: UserVideoRateType) {
+ private setVideoRate (id: string, rateType: UserVideoRateType) {
const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
const body: UserVideoRateUpdate = {
rating: rateType