import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
-import { ServerService } from '@app/core'
+import { ServerService, AuthService } 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 { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
+import { FfprobeData } from 'fluent-ffmpeg'
export interface VideosProvider {
getVideos (parameters: {
videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
- categoryOneOf?: number,
+ categoryOneOf?: number[],
languageOneOf?: string[]
+ nsfwPolicy: NSFWPolicyType
}): Observable<ResultList<Video>>
}
constructor (
private authHttp: HttpClient,
+ private authService: AuthService,
+ private userService: UserService,
private restExtractor: RestExtractor,
private restService: RestService,
private serverService: ServerService,
getVideoChannelVideos (
videoChannel: VideoChannel,
videoPagination: ComponentPaginationLight,
- sort: VideoSortField
+ sort: VideoSortField,
+ nsfwPolicy?: NSFWPolicyType
): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (nsfwPolicy) {
+ params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy))
+ }
+
return this.authHttp
.get<ResultList<Video>>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.nameWithHost + '/videos', { params })
.pipe(
videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
- categoryOneOf?: number,
+ categoryOneOf?: number[],
languageOneOf?: string[],
- skipCount?: boolean
+ skipCount?: boolean,
+ nsfwPolicy?: NSFWPolicyType
}): Observable<ResultList<Video>> {
- const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount } = parameters
+ const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfwPolicy } = parameters
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
params = this.restService.addRestGetParams(params, pagination, sort)
if (filter) params = params.set('filter', filter)
- if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
if (skipCount) params = params.set('skipCount', skipCount + '')
+ if (nsfwPolicy) {
+ params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy))
+ }
+
if (languageOneOf) {
for (const l of languageOneOf) {
params = params.append('languageOneOf[]', l)
}
}
+ if (categoryOneOf) {
+ for (const c of categoryOneOf) {
+ params = params.append('categoryOneOf[]', c + '')
+ }
+ }
+
return this.authHttp
.get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
.pipe(
return feeds
}
- getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number) {
+ getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number[]) {
let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)
if (filter) params = params.set('filter', filter)
- if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
+ if (categoryOneOf) {
+ for (const c of categoryOneOf) {
+ params = params.append('categoryOneOf[]', c + '')
+ }
+ }
return this.buildBaseFeedUrls(params)
}
return this.buildBaseFeedUrls(params)
}
+ getVideoFileMetadata (metadataUrl: string) {
+ return this.authHttp
+ .get<FfprobeData>(metadataUrl)
+ .pipe(
+ catchError(err => this.restExtractor.handleError(err))
+ )
+ }
+
removeVideo (id: number) {
return this.authHttp
.delete(VideoService.BASE_VIDEO_URL + id)
return base.filter(o => !!privacies.find(p => p.id === o.id))
}
+ nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) {
+ return nsfwPolicy === 'do_not_list'
+ ? 'false'
+ : 'both'
+ }
+
private setVideoRate (id: number, rateType: UserVideoRateType) {
const url = VideoService.BASE_VIDEO_URL + id + '/rate'
const body: UserVideoRateUpdate = {