-import { Observable } from 'rxjs'
-import { catchError, map, switchMap } from 'rxjs/operators'
-import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
+import { Observable, of, throwError } from 'rxjs'
+import { catchError, map, mergeMap, switchMap } from 'rxjs/operators'
+import { HttpClient, HttpErrorResponse, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService, AuthService } from '@app/core'
import { objectToFormData } from '@app/helpers'
VideoFilter,
VideoPrivacy,
VideoSortField,
- VideoUpdate,
- VideoCreate
+ VideoUpdate
} from '@shared/models'
import { environment } from '../../../../environments/environment'
import { Account } from '../account/account.model'
export class VideoService implements VideosProvider {
static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/'
static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.'
+ static BASE_SUBSCRIPTION_FEEDS_URL = environment.apiUrl + '/feeds/subscriptions.'
constructor (
private authHttp: HttpClient,
private restExtractor: RestExtractor,
private restService: RestService,
- private serverService: ServerService,
- private authService: AuthService
+ private serverService: ServerService
) {}
getVideoViewUrl (uuid: string) {
)
}
- buildBaseFeedUrls (params: HttpParams) {
+ buildBaseFeedUrls (params: HttpParams, base = VideoService.BASE_FEEDS_URL) {
const feeds = [
{
format: FeedFormat.RSS,
label: 'media rss 2.0',
- url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
+ url: base + FeedFormat.RSS.toLowerCase()
},
{
format: FeedFormat.ATOM,
label: 'atom 1.0',
- url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
+ url: base + FeedFormat.ATOM.toLowerCase()
},
{
format: FeedFormat.JSON,
label: 'json 1.0',
- url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
+ url: base + FeedFormat.JSON.toLowerCase()
}
]
return this.buildBaseFeedUrls(params)
}
- async getVideoSubscriptionFeedUrls (accountId: number) {
+ getVideoSubscriptionFeedUrls (accountId: number, feedToken: string) {
let params = this.restService.addRestGetParams(new HttpParams())
params = params.set('accountId', accountId.toString())
-
- const { feedToken } = await this.authService.getScopedTokens()
params = params.set('token', feedToken)
- return this.buildBaseFeedUrls(params)
+ return this.buildBaseFeedUrls(params, VideoService.BASE_SUBSCRIPTION_FEEDS_URL)
}
getVideoFileMetadata (metadataUrl: string) {