diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-03 11:06:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-03 16:42:15 +0200 |
commit | 1fd61899eaea245a5844e33e21f04b2562f16e5e (patch) | |
tree | 2a1d51b37b12219cade35e189d62686cd0fec105 /shared | |
parent | dfcb6f50a607b6b402b4f8fa3d43792d61c912a5 (diff) | |
download | PeerTube-1fd61899eaea245a5844e33e21f04b2562f16e5e.tar.gz PeerTube-1fd61899eaea245a5844e33e21f04b2562f16e5e.tar.zst PeerTube-1fd61899eaea245a5844e33e21f04b2562f16e5e.zip |
Add ability to filter my videos by live
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 16 | ||||
-rw-r--r-- | shared/models/search/boolean-both-query.model.ts | 1 | ||||
-rw-r--r-- | shared/models/search/index.ts | 3 | ||||
-rw-r--r-- | shared/models/search/nsfw-query.model.ts | 1 | ||||
-rw-r--r-- | shared/models/search/videos-common-query.model.ts | 28 | ||||
-rw-r--r-- | shared/models/search/videos-search-query.model.ts | 22 |
6 files changed, 48 insertions, 23 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 67fe82d41..a0143b0ef 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -8,6 +8,7 @@ import * as request from 'supertest' | |||
8 | import { v4 as uuidv4 } from 'uuid' | 8 | import { v4 as uuidv4 } from 'uuid' |
9 | import validator from 'validator' | 9 | import validator from 'validator' |
10 | import { HttpStatusCode } from '@shared/core-utils' | 10 | import { HttpStatusCode } from '@shared/core-utils' |
11 | import { VideosCommonQuery } from '@shared/models' | ||
11 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' | 12 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' |
12 | import { VideoDetails, VideoPrivacy } from '../../models/videos' | 13 | import { VideoDetails, VideoPrivacy } from '../../models/videos' |
13 | import { | 14 | import { |
@@ -195,6 +196,18 @@ function getMyVideos (url: string, accessToken: string, start: number, count: nu | |||
195 | .expect('Content-Type', /json/) | 196 | .expect('Content-Type', /json/) |
196 | } | 197 | } |
197 | 198 | ||
199 | function getMyVideosWithFilter (url: string, accessToken: string, query: { isLive?: boolean }) { | ||
200 | const path = '/api/v1/users/me/videos' | ||
201 | |||
202 | return makeGetRequest({ | ||
203 | url, | ||
204 | path, | ||
205 | token: accessToken, | ||
206 | query, | ||
207 | statusCodeExpected: HttpStatusCode.OK_200 | ||
208 | }) | ||
209 | } | ||
210 | |||
198 | function getAccountVideos ( | 211 | function getAccountVideos ( |
199 | url: string, | 212 | url: string, |
200 | accessToken: string, | 213 | accessToken: string, |
@@ -295,7 +308,7 @@ function getVideosListSort (url: string, sort: string) { | |||
295 | .expect('Content-Type', /json/) | 308 | .expect('Content-Type', /json/) |
296 | } | 309 | } |
297 | 310 | ||
298 | function getVideosWithFilters (url: string, query: { tagsAllOf: string[], categoryOneOf: number[] | number }) { | 311 | function getVideosWithFilters (url: string, query: VideosCommonQuery) { |
299 | const path = '/api/v1/videos' | 312 | const path = '/api/v1/videos' |
300 | 313 | ||
301 | return request(url) | 314 | return request(url) |
@@ -751,6 +764,7 @@ export { | |||
751 | completeVideoCheck, | 764 | completeVideoCheck, |
752 | checkVideoFilesWereRemoved, | 765 | checkVideoFilesWereRemoved, |
753 | getPlaylistVideos, | 766 | getPlaylistVideos, |
767 | getMyVideosWithFilter, | ||
754 | uploadVideoAndGetId, | 768 | uploadVideoAndGetId, |
755 | getLocalIdByUUID, | 769 | getLocalIdByUUID, |
756 | getVideoIdFromUUID | 770 | getVideoIdFromUUID |
diff --git a/shared/models/search/boolean-both-query.model.ts b/shared/models/search/boolean-both-query.model.ts new file mode 100644 index 000000000..57b0e8d44 --- /dev/null +++ b/shared/models/search/boolean-both-query.model.ts | |||
@@ -0,0 +1 @@ | |||
export type BooleanBothQuery = 'true' | 'false' | 'both' | |||
diff --git a/shared/models/search/index.ts b/shared/models/search/index.ts index e2d0ab620..697ceccb1 100644 --- a/shared/models/search/index.ts +++ b/shared/models/search/index.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | export * from './nsfw-query.model' | 1 | export * from './boolean-both-query.model' |
2 | export * from './search-target-query.model' | 2 | export * from './search-target-query.model' |
3 | export * from './videos-common-query.model' | ||
3 | export * from './videos-search-query.model' | 4 | export * from './videos-search-query.model' |
4 | export * from './video-channels-search-query.model' | 5 | export * from './video-channels-search-query.model' |
diff --git a/shared/models/search/nsfw-query.model.ts b/shared/models/search/nsfw-query.model.ts deleted file mode 100644 index 6b6ad1991..000000000 --- a/shared/models/search/nsfw-query.model.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type NSFWQuery = 'true' | 'false' | 'both' | ||
diff --git a/shared/models/search/videos-common-query.model.ts b/shared/models/search/videos-common-query.model.ts new file mode 100644 index 000000000..bd02489ea --- /dev/null +++ b/shared/models/search/videos-common-query.model.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | import { VideoFilter } from '../videos' | ||
2 | import { BooleanBothQuery } from './boolean-both-query.model' | ||
3 | |||
4 | // These query parameters can be used with any endpoint that list videos | ||
5 | export interface VideosCommonQuery { | ||
6 | start?: number | ||
7 | count?: number | ||
8 | sort?: string | ||
9 | |||
10 | nsfw?: BooleanBothQuery | ||
11 | |||
12 | isLive?: boolean | ||
13 | |||
14 | categoryOneOf?: number[] | ||
15 | |||
16 | licenceOneOf?: number[] | ||
17 | |||
18 | languageOneOf?: string[] | ||
19 | |||
20 | tagsOneOf?: string[] | ||
21 | tagsAllOf?: string[] | ||
22 | |||
23 | filter?: VideoFilter | ||
24 | } | ||
25 | |||
26 | export interface VideosWithSearchCommonQuery extends VideosCommonQuery { | ||
27 | search?: string | ||
28 | } | ||
diff --git a/shared/models/search/videos-search-query.model.ts b/shared/models/search/videos-search-query.model.ts index 3ce4ff73e..406f6cab2 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/shared/models/search/videos-search-query.model.ts | |||
@@ -1,33 +1,15 @@ | |||
1 | import { VideoFilter } from '../videos' | ||
2 | import { NSFWQuery } from './nsfw-query.model' | ||
3 | import { SearchTargetQuery } from './search-target-query.model' | 1 | import { SearchTargetQuery } from './search-target-query.model' |
2 | import { VideosCommonQuery } from './videos-common-query.model' | ||
4 | 3 | ||
5 | export interface VideosSearchQuery extends SearchTargetQuery { | 4 | export interface VideosSearchQuery extends SearchTargetQuery, VideosCommonQuery { |
6 | search?: string | 5 | search?: string |
7 | 6 | ||
8 | start?: number | ||
9 | count?: number | ||
10 | sort?: string | ||
11 | |||
12 | startDate?: string // ISO 8601 | 7 | startDate?: string // ISO 8601 |
13 | endDate?: string // ISO 8601 | 8 | endDate?: string // ISO 8601 |
14 | 9 | ||
15 | originallyPublishedStartDate?: string // ISO 8601 | 10 | originallyPublishedStartDate?: string // ISO 8601 |
16 | originallyPublishedEndDate?: string // ISO 8601 | 11 | originallyPublishedEndDate?: string // ISO 8601 |
17 | 12 | ||
18 | nsfw?: NSFWQuery | ||
19 | |||
20 | categoryOneOf?: number[] | ||
21 | |||
22 | licenceOneOf?: number[] | ||
23 | |||
24 | languageOneOf?: string[] | ||
25 | |||
26 | tagsOneOf?: string[] | ||
27 | tagsAllOf?: string[] | ||
28 | |||
29 | durationMin?: number // seconds | 13 | durationMin?: number // seconds |
30 | durationMax?: number // seconds | 14 | durationMax?: number // seconds |
31 | |||
32 | filter?: VideoFilter | ||
33 | } | 15 | } |