+ getVideos (
+ videoPagination: ComponentPagination,
+ sort: VideoSortField,
+ filter?: VideoFilter
+ ): Observable<{ videos: Video[], totalVideos: number }> {
+ const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
+
+ let params = new HttpParams()
+ params = this.restService.addRestGetParams(params, pagination, sort)
+
+ if (filter) {
+ params = params.set('filter', filter)
+ }
+
+ return this.authHttp
+ .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
+ .pipe(
+ switchMap(res => this.extractVideos(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
+ }
+
+ buildBaseFeedUrls (params: HttpParams) {
+ const feeds = [
+ {
+ label: 'rss 2.0',
+ url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
+ },
+ {
+ label: 'atom 1.0',
+ url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
+ },
+ {
+ label: 'json 1.0',
+ url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
+ }
+ ]
+
+ if (params && params.keys().length !== 0) {
+ for (const feed of feeds) {
+ feed.url += '?' + params.toString()
+ }
+ }
+
+ return feeds
+ }
+
+ getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter) {
+ let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)
+
+ if (filter) params = params.set('filter', filter)
+
+ return this.buildBaseFeedUrls(params)
+ }
+
+ getAccountFeedUrls (accountId: number) {
+ let params = this.restService.addRestGetParams(new HttpParams())
+ params = params.set('accountId', accountId.toString())
+
+ return this.buildBaseFeedUrls(params)
+ }
+
+ getVideoChannelFeedUrls (videoChannelId: number) {
+ let params = this.restService.addRestGetParams(new HttpParams())
+ params = params.set('videoChannelId', videoChannelId.toString())
+
+ return this.buildBaseFeedUrls(params)
+ }
+
+ searchVideos (
+ search: string,
+ videoPagination: ComponentPagination,
+ sort: VideoSortField
+ ): Observable<{ videos: Video[], totalVideos: number }> {