+ // Choose if we display by default the account or the channel
+ buildDefaultOwnerDisplayType (video: Video) {
+ const accountName = video.account.name
+
+ // If the video channel name is an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12)
+ // Or has not been customized (default created channel display name)
+ // -> Use the account name
+ if (
+ video.channel.displayName === `Default ${accountName} channel` ||
+ video.channel.displayName === `Main ${accountName} channel` ||
+ video.channel.name.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)
+ ) {
+ return 'account' as 'account'
+ }
+
+ return 'videoChannel' as 'videoChannel'
+ }
+
+ buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
+ const {
+ params,
+ videoPagination,
+ sort,
+ isLocal,
+ include,
+ categoryOneOf,
+ languageOneOf,
+ privacyOneOf,
+ skipCount,
+ nsfwPolicy,
+ isLive,
+ nsfw
+ } = options
+
+ const pagination = videoPagination
+ ? this.restService.componentToRestPagination(videoPagination)
+ : undefined
+
+ let newParams = this.restService.addRestGetParams(params, pagination, this.buildListSort(sort))
+
+ if (skipCount) newParams = newParams.set('skipCount', skipCount + '')
+
+ if (isLocal !== undefined) newParams = newParams.set('isLocal', isLocal)
+ if (include !== undefined) newParams = newParams.set('include', include)
+ if (isLive !== undefined) newParams = newParams.set('isLive', isLive)
+ if (nsfw !== undefined) newParams = newParams.set('nsfw', nsfw)
+ if (nsfwPolicy !== undefined) newParams = newParams.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy))
+ if (languageOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'languageOneOf', languageOneOf)
+ if (categoryOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'categoryOneOf', categoryOneOf)
+ if (privacyOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'privacyOneOf', privacyOneOf)
+
+ return newParams
+ }
+
+ private buildListSort (sortArg: VideoSortField | SortMeta) {
+ const sort = this.restService.buildSortString(sortArg)
+
+ if (typeof sort === 'string') {
+ // Silently use the best algorithm for logged in users if they chose the hot algorithm
+ if (
+ this.auth.isLoggedIn() &&
+ (sort === 'hot' || sort === '-hot')
+ ) {
+ return sort.replace('hot', 'best')
+ }
+
+ return sort
+ }
+ }
+
+ private setVideoRate (id: string, rateType: UserVideoRateType) {
+ const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`