aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/search/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/search/videos.ts')
-rw-r--r--shared/extra-utils/search/videos.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/shared/extra-utils/search/videos.ts b/shared/extra-utils/search/videos.ts
index ba4627017..5cf8d8cf0 100644
--- a/shared/extra-utils/search/videos.ts
+++ b/shared/extra-utils/search/videos.ts
@@ -6,9 +6,11 @@ import { immutableAssign } from '../miscs/miscs'
6 6
7function searchVideo (url: string, search: string) { 7function searchVideo (url: string, search: string) {
8 const path = '/api/v1/search/videos' 8 const path = '/api/v1/search/videos'
9
10 const query = { sort: '-publishedAt', search: search }
9 const req = request(url) 11 const req = request(url)
10 .get(path) 12 .get(path)
11 .query({ sort: '-publishedAt', search }) 13 .query(query)
12 .set('Accept', 'application/json') 14 .set('Accept', 'application/json')
13 15
14 return req.expect(200) 16 return req.expect(200)
@@ -30,11 +32,15 @@ function searchVideoWithToken (url: string, search: string, token: string, query
30function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { 32function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) {
31 const path = '/api/v1/search/videos' 33 const path = '/api/v1/search/videos'
32 34
35 const query = {
36 start,
37 search,
38 count
39 }
40
33 const req = request(url) 41 const req = request(url)
34 .get(path) 42 .get(path)
35 .query({ start }) 43 .query(query)
36 .query({ search })
37 .query({ count })
38 44
39 if (sort) req.query({ sort }) 45 if (sort) req.query({ sort })
40 46
@@ -46,10 +52,11 @@ function searchVideoWithPagination (url: string, search: string, start: number,
46function searchVideoWithSort (url: string, search: string, sort: string) { 52function searchVideoWithSort (url: string, search: string, sort: string) {
47 const path = '/api/v1/search/videos' 53 const path = '/api/v1/search/videos'
48 54
55 const query = { search, sort }
56
49 return request(url) 57 return request(url)
50 .get(path) 58 .get(path)
51 .query({ search }) 59 .query(query)
52 .query({ sort })
53 .set('Accept', 'application/json') 60 .set('Accept', 'application/json')
54 .expect(200) 61 .expect(200)
55 .expect('Content-Type', /json/) 62 .expect('Content-Type', /json/)