X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo.service.ts;h=ef489648c6c48f088d7e66a507bd3f4a49909d7f;hb=21d141c296541f41e399ec68aa7fa85e53d0dcb8;hp=c0339dd39d806cca4efc1a402a9eec881c93db3b;hpb=156c50af3085468a47b8ae73fe8cfcae46b42398;p=oweals%2Fpeertube.git diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index c0339dd39..ef489648c 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -6,11 +6,11 @@ import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } fr import { ResultList } from '../../../../../shared/models/result-list.model' import { UserVideoRate, + UserVideoRateType, UserVideoRateUpdate, VideoConstant, VideoFilter, VideoPrivacy, - VideoRateType, VideoUpdate } from '../../../../../shared/models/videos' import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' @@ -31,6 +31,8 @@ import { ServerService } from '@app/core' import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { I18n } from '@ngx-translate/i18n-polyfill' +import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' +import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' export interface VideosProvider { getVideos ( @@ -81,6 +83,7 @@ export class VideoService implements VideosProvider { const description = video.description || null const support = video.support || null const scheduleUpdate = video.scheduleUpdate || null + const originallyPublishedAt = video.originallyPublishedAt || null const body: VideoUpdate = { name: video.name, @@ -95,10 +98,11 @@ export class VideoService implements VideosProvider { nsfw: video.nsfw, waitTranscoding: video.waitTranscoding, commentsEnabled: video.commentsEnabled, - downloadingEnabled: video.downloadingEnabled, + downloadEnabled: video.downloadEnabled, thumbnailfile: video.thumbnailfile, previewfile: video.previewfile, - scheduleUpdate + scheduleUpdate, + originallyPublishedAt } const data = objectToFormData(body) @@ -168,6 +172,23 @@ export class VideoService implements VideosProvider { ) } + getPlaylistVideos ( + videoPlaylistId: number | string, + videoPagination: ComponentPagination + ): Observable<{ videos: Video[], totalVideos: number }> { + const pagination = this.restService.componentPaginationToRestPagination(videoPagination) + + let params = new HttpParams() + params = this.restService.addRestGetParams(params, pagination) + + return this.authHttp + .get>(VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + videoPlaylistId + '/videos', { params }) + .pipe( + switchMap(res => this.extractVideos(res)), + catchError(err => this.restExtractor.handleError(err)) + ) + } + getUserSubscriptionVideos ( videoPagination: ComponentPagination, sort: VideoSortField @@ -275,9 +296,9 @@ export class VideoService implements VideosProvider { loadCompleteDescription (descriptionPath: string) { return this.authHttp - .get(environment.apiUrl + descriptionPath) + .get<{ description: string }>(environment.apiUrl + descriptionPath) .pipe( - map(res => res[ 'description' ]), + map(res => res.description), catchError(err => this.restExtractor.handleError(err)) ) } @@ -333,7 +354,7 @@ export class VideoService implements VideosProvider { return privacies } - private setVideoRate (id: number, rateType: VideoRateType) { + private setVideoRate (id: number, rateType: UserVideoRateType) { const url = VideoService.BASE_VIDEO_URL + id + '/rate' const body: UserVideoRateUpdate = { rating: rateType