aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/video-playlists.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/videos/video-playlists.ts')
-rw-r--r--shared/extra-utils/videos/video-playlists.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts
index 5bcc02570..c6f799e5d 100644
--- a/shared/extra-utils/videos/video-playlists.ts
+++ b/shared/extra-utils/videos/video-playlists.ts
@@ -10,6 +10,7 @@ import { root } from '..'
10import { readdir } from 'fs-extra' 10import { readdir } from 'fs-extra'
11import { expect } from 'chai' 11import { expect } from 'chai'
12import { VideoPlaylistType } from '../../models/videos/playlist/video-playlist-type.model' 12import { VideoPlaylistType } from '../../models/videos/playlist/video-playlist-type.model'
13import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
13 14
14function getVideoPlaylistsList (url: string, start: number, count: number, sort?: string) { 15function getVideoPlaylistsList (url: string, start: number, count: number, sort?: string) {
15 const path = '/api/v1/video-playlists' 16 const path = '/api/v1/video-playlists'
@@ -24,7 +25,7 @@ function getVideoPlaylistsList (url: string, start: number, count: number, sort?
24 url, 25 url,
25 path, 26 path,
26 query, 27 query,
27 statusCodeExpected: 200 28 statusCodeExpected: HttpStatusCode.OK_200
28 }) 29 })
29} 30}
30 31
@@ -41,7 +42,7 @@ function getVideoChannelPlaylistsList (url: string, videoChannelName: string, st
41 url, 42 url,
42 path, 43 path,
43 query, 44 query,
44 statusCodeExpected: 200 45 statusCodeExpected: HttpStatusCode.OK_200
45 }) 46 })
46} 47}
47 48
@@ -59,7 +60,7 @@ function getAccountPlaylistsList (url: string, accountName: string, start: numbe
59 url, 60 url,
60 path, 61 path,
61 query, 62 query,
62 statusCodeExpected: 200 63 statusCodeExpected: HttpStatusCode.OK_200
63 }) 64 })
64} 65}
65 66
@@ -86,11 +87,11 @@ function getAccountPlaylistsListWithToken (
86 token, 87 token,
87 path, 88 path,
88 query, 89 query,
89 statusCodeExpected: 200 90 statusCodeExpected: HttpStatusCode.OK_200
90 }) 91 })
91} 92}
92 93
93function getVideoPlaylist (url: string, playlistId: number | string, statusCodeExpected = 200) { 94function getVideoPlaylist (url: string, playlistId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
94 const path = '/api/v1/video-playlists/' + playlistId 95 const path = '/api/v1/video-playlists/' + playlistId
95 96
96 return makeGetRequest({ 97 return makeGetRequest({
@@ -100,7 +101,7 @@ function getVideoPlaylist (url: string, playlistId: number | string, statusCodeE
100 }) 101 })
101} 102}
102 103
103function getVideoPlaylistWithToken (url: string, token: string, playlistId: number | string, statusCodeExpected = 200) { 104function getVideoPlaylistWithToken (url: string, token: string, playlistId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
104 const path = '/api/v1/video-playlists/' + playlistId 105 const path = '/api/v1/video-playlists/' + playlistId
105 106
106 return makeGetRequest({ 107 return makeGetRequest({
@@ -111,7 +112,7 @@ function getVideoPlaylistWithToken (url: string, token: string, playlistId: numb
111 }) 112 })
112} 113}
113 114
114function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = 204) { 115function deleteVideoPlaylist (url: string, token: string, playlistId: number | string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
115 const path = '/api/v1/video-playlists/' + playlistId 116 const path = '/api/v1/video-playlists/' + playlistId
116 117
117 return makeDeleteRequest({ 118 return makeDeleteRequest({
@@ -143,7 +144,7 @@ function createVideoPlaylist (options: {
143 token: options.token, 144 token: options.token,
144 fields, 145 fields,
145 attaches, 146 attaches,
146 statusCodeExpected: options.expectedStatus || 200 147 statusCodeExpected: options.expectedStatus || HttpStatusCode.OK_200
147 }) 148 })
148} 149}
149 150
@@ -169,7 +170,7 @@ function updateVideoPlaylist (options: {
169 token: options.token, 170 token: options.token,
170 fields, 171 fields,
171 attaches, 172 attaches,
172 statusCodeExpected: options.expectedStatus || 204 173 statusCodeExpected: options.expectedStatus || HttpStatusCode.NO_CONTENT_204
173 }) 174 })
174} 175}
175 176
@@ -189,7 +190,7 @@ async function addVideoInPlaylist (options: {
189 path, 190 path,
190 token: options.token, 191 token: options.token,
191 fields: options.elementAttrs, 192 fields: options.elementAttrs,
192 statusCodeExpected: options.expectedStatus || 200 193 statusCodeExpected: options.expectedStatus || HttpStatusCode.OK_200
193 }) 194 })
194} 195}
195 196
@@ -208,7 +209,7 @@ function updateVideoPlaylistElement (options: {
208 path, 209 path,
209 token: options.token, 210 token: options.token,
210 fields: options.elementAttrs, 211 fields: options.elementAttrs,
211 statusCodeExpected: options.expectedStatus || 204 212 statusCodeExpected: options.expectedStatus || HttpStatusCode.NO_CONTENT_204
212 }) 213 })
213} 214}
214 215
@@ -225,7 +226,7 @@ function removeVideoFromPlaylist (options: {
225 url: options.url, 226 url: options.url,
226 path, 227 path,
227 token: options.token, 228 token: options.token,
228 statusCodeExpected: options.expectedStatus || 204 229 statusCodeExpected: options.expectedStatus || HttpStatusCode.NO_CONTENT_204
229 }) 230 })
230} 231}
231 232
@@ -247,7 +248,7 @@ function reorderVideosPlaylist (options: {
247 path, 248 path,
248 token: options.token, 249 token: options.token,
249 fields: options.elementAttrs, 250 fields: options.elementAttrs,
250 statusCodeExpected: options.expectedStatus || 204 251 statusCodeExpected: options.expectedStatus || HttpStatusCode.NO_CONTENT_204
251 }) 252 })
252} 253}
253 254
@@ -274,7 +275,7 @@ function getVideoPlaylistPrivacies (url: string) {
274 return makeGetRequest({ 275 return makeGetRequest({
275 url, 276 url,
276 path, 277 path,
277 statusCodeExpected: 200 278 statusCodeExpected: HttpStatusCode.OK_200
278 }) 279 })
279} 280}
280 281
@@ -286,7 +287,7 @@ function doVideosExistInMyPlaylist (url: string, token: string, videoIds: number
286 token, 287 token,
287 path, 288 path,
288 query: { videoIds }, 289 query: { videoIds },
289 statusCodeExpected: 200 290 statusCodeExpected: HttpStatusCode.OK_200
290 }) 291 })
291} 292}
292 293