ActivityPub-federated video streaming platform using P2P directly in your web browser
Filter by category (#720)
PhieF61b909b9bf84
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.tsindex a468d3231f..d60536e20e 100644--- a/client/src/app/shared/video/abstract-video-list.ts+++ b/client/src/app/shared/video/abstract-video-list.ts@@ -24,6 +24,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {totalItems: null}sort: VideoSortField = '-publishedAt'+ category?: numberdefaultSort: VideoSortField = '-publishedAt'syndicationItems = []@@ -167,7 +168,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {protected loadRouteParams (routeParams: { [ key: string ]: any }) {this.sort = routeParams['sort'] as VideoSortField || this.defaultSort-+ this.category = routeParams['category']if (routeParams['page'] !== undefined) {this.pagination.currentPage = parseInt(routeParams['page'], 10)} else {diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.tsindex 2da36ff1b7..4783adf42b 100644--- a/client/src/app/shared/video/video.service.ts+++ b/client/src/app/shared/video/video.service.ts@@ -158,7 +158,8 @@ export class VideoService {getVideos (videoPagination: ComponentPagination,sort: VideoSortField,- filter?: VideoFilter+ filter?: VideoFilter,+ category?: number): Observable<{ videos: Video[], totalVideos: number }> {const pagination = this.restService.componentPaginationToRestPagination(videoPagination)@@ -169,6 +170,10 @@ export class VideoService {params = params.set('filter', filter)}+ if (category) {+ params = params.set('category', category + '')+ }+return this.authHttp.get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }).pipe(@@ -202,11 +207,13 @@ export class VideoService {return feeds}- getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter) {+ getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, category?: number) {let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)if (filter) params = params.set('filter', filter)+ if (category) params = params.set('category', category + '')+return this.buildBaseFeedUrls(params)}diff --git a/client/src/app/videos/video-list/video-local.component.ts b/client/src/app/videos/video-list/video-local.component.tsindex dbe1d937d2..de460ea60e 100644--- a/client/src/app/videos/video-list/video-local.component.ts+++ b/client/src/app/videos/video-list/video-local.component.ts@@ -50,10 +50,10 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, OngetVideosObservable (page: number) {const newPagination = immutableAssign(this.pagination, { currentPage: page })- return this.videoService.getVideos(newPagination, this.sort, this.filter)+ return this.videoService.getVideos(newPagination, this.sort, this.filter, this.category)}generateSyndicationList () {- this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter)+ this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.category)}}diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.tsindex 004a491683..75688731dc 100644--- a/client/src/app/videos/video-list/video-recently-added.component.ts+++ b/client/src/app/videos/video-list/video-recently-added.component.ts@@ -48,10 +48,10 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements OngetVideosObservable (page: number) {const newPagination = immutableAssign(this.pagination, { currentPage: page })- return this.videoService.getVideos(newPagination, this.sort)+ return this.videoService.getVideos(newPagination, this.sort, undefined, this.category)}generateSyndicationList () {- this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort)+ this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.category)}}diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.tsindex f2174aa145..3738b95b1f 100644--- a/client/src/app/videos/video-list/video-trending.component.ts+++ b/client/src/app/videos/video-list/video-trending.component.ts@@ -47,10 +47,10 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,getVideosObservable (page: number) {const newPagination = immutableAssign(this.pagination, { currentPage: page })- return this.videoService.getVideos(newPagination, this.sort)+ return this.videoService.getVideos(newPagination, this.sort, undefined, this.category)}generateSyndicationList () {- this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort)+ this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.category)}}diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.tsindex ca800a9a8b..b4ced8c1e6 100644--- a/server/controllers/api/videos/index.ts+++ b/server/controllers/api/videos/index.ts@@ -407,6 +407,7 @@ async function listVideos (req: express.Request, res: express.Response, next: exstart: req.query.start,count: req.query.count,sort: req.query.sort,+ category: req.query.category,hideNSFW: isNSFWHidden(res),filter: req.query.filter as VideoFilter,withFiles: falsediff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 0041e4d387..0af70cadf8 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -106,6 +106,7 @@ export enum ScopeNames {actorId: number,hideNSFW: boolean,filter?: VideoFilter,+ category?: number,withFiles?: boolean,accountId?: number,videoChannelId?: number@@ -215,6 +216,10 @@ export enum ScopeNames {query.where['nsfw'] = false}+ if (options.category) {+ query.where['category'] = options.category+ }+if (options.accountId) {accountInclude.where = {id: options.accountId@@ -730,6 +735,7 @@ export class VideoModel extends Model<VideoModel> {sort: string,hideNSFW: boolean,withFiles: boolean,+ category?: number,filter?: VideoFilter,accountId?: number,videoChannelId?: number@@ -746,6 +752,7 @@ export class VideoModel extends Model<VideoModel> {ScopeNames.AVAILABLE_FOR_LIST, {actorId: serverActor.id,hideNSFW: options.hideNSFW,+ category: options.category,filter: options.filter,withFiles: options.withFiles,accountId: options.accountId,diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 4b7bc23b4a..89e510cb4b 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -529,6 +529,11 @@ paths:produces:- application/jsonparameters:+ - name: category+ in: query+ required: false+ type: number+ description: category id of the video- name: startin: queryrequired: false