aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/video-playlist.ts2
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts2
-rw-r--r--server/tests/api/videos/video-playlists.ts60
-rw-r--r--shared/server-commands/videos/playlists-command.ts6
-rw-r--r--support/doc/api/openapi.yaml67
5 files changed, 126 insertions, 11 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index bcb60e265..08b0f971d 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -139,7 +139,7 @@ async function listVideoPlaylists (req: express.Request, res: express.Response)
139 start: req.query.start, 139 start: req.query.start,
140 count: req.query.count, 140 count: req.query.count,
141 sort: req.query.sort, 141 sort: req.query.sort,
142 type: req.query.type 142 type: req.query.playlistType
143 }) 143 })
144 144
145 return res.json(getFormattedObjects(resultList.data, resultList.total)) 145 return res.json(getFormattedObjects(resultList.data, resultList.total))
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index e4b7e5c56..c631a16f8 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -142,7 +142,7 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
142 142
143 const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary 143 const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary
144 144
145 // Video is unlisted, check we used the uuid to fetch it 145 // Playlist is unlisted, check we used the uuid to fetch it
146 if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) { 146 if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) {
147 if (isUUIDValid(req.params.playlistId)) return next() 147 if (isUUIDValid(req.params.playlistId)) return next()
148 148
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index e8e653382..d9c5bdf16 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -114,7 +114,7 @@ describe('Test video playlists', function () {
114 await waitJobs(servers) 114 await waitJobs(servers)
115 }) 115 })
116 116
117 describe('Get default playlists', function () { 117 describe('Check playlists filters and privacies', function () {
118 118
119 it('Should list video playlist privacies', async function () { 119 it('Should list video playlist privacies', async function () {
120 const privacies = await commands[0].getPrivacies() 120 const privacies = await commands[0].getPrivacies()
@@ -123,9 +123,21 @@ describe('Test video playlists', function () {
123 expect(privacies[3]).to.equal('Private') 123 expect(privacies[3]).to.equal('Private')
124 }) 124 })
125 125
126 it('Should list watch later playlist', async function () { 126 it('Should filter on playlist type', async function () {
127 this.timeout(30000)
128
127 const token = servers[0].accessToken 129 const token = servers[0].accessToken
128 130
131 await commands[0].create({
132 attributes: {
133 displayName: 'my super playlist',
134 privacy: VideoPlaylistPrivacy.PUBLIC,
135 description: 'my super description',
136 thumbnailfile: 'thumbnail.jpg',
137 videoChannelId: servers[0].store.channel.id
138 }
139 })
140
129 { 141 {
130 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER }) 142 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER })
131 143
@@ -136,13 +148,51 @@ describe('Test video playlists', function () {
136 expect(playlist.displayName).to.equal('Watch later') 148 expect(playlist.displayName).to.equal('Watch later')
137 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER) 149 expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
138 expect(playlist.type.label).to.equal('Watch later') 150 expect(playlist.type.label).to.equal('Watch later')
151 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
139 } 152 }
140 153
141 { 154 {
142 const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.REGULAR }) 155 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.WATCH_LATER })
156 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.WATCH_LATER })
143 157
144 expect(body.total).to.equal(0) 158 for (const body of [ bodyList, bodyChannel ]) {
145 expect(body.data).to.have.lengthOf(0) 159 expect(body.total).to.equal(0)
160 expect(body.data).to.have.lengthOf(0)
161 }
162 }
163
164 {
165 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
166 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
167
168 let playlist: VideoPlaylist = null
169 for (const body of [ bodyList, bodyChannel ]) {
170
171 expect(body.total).to.equal(1)
172 expect(body.data).to.have.lengthOf(1)
173
174 playlist = body.data[0]
175 expect(playlist.displayName).to.equal('my super playlist')
176 expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
177 expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
178 }
179
180 await commands[0].update({
181 playlistId: playlist.id,
182 attributes: {
183 privacy: VideoPlaylistPrivacy.PRIVATE
184 }
185 })
186 }
187
188 {
189 const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
190 const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
191
192 for (const body of [ bodyList, bodyChannel ]) {
193 expect(body.total).to.equal(0)
194 expect(body.data).to.have.lengthOf(0)
195 }
146 } 196 }
147 197
148 { 198 {
diff --git a/shared/server-commands/videos/playlists-command.ts b/shared/server-commands/videos/playlists-command.ts
index 516da0bf7..da3bef7b0 100644
--- a/shared/server-commands/videos/playlists-command.ts
+++ b/shared/server-commands/videos/playlists-command.ts
@@ -24,9 +24,10 @@ export class PlaylistsCommand extends AbstractCommand {
24 start?: number 24 start?: number
25 count?: number 25 count?: number
26 sort?: string 26 sort?: string
27 playlistType?: VideoPlaylistType
27 }) { 28 }) {
28 const path = '/api/v1/video-playlists' 29 const path = '/api/v1/video-playlists'
29 const query = pick(options, [ 'start', 'count', 'sort' ]) 30 const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ])
30 31
31 return this.getRequestBody<ResultList<VideoPlaylist>>({ 32 return this.getRequestBody<ResultList<VideoPlaylist>>({
32 ...options, 33 ...options,
@@ -43,9 +44,10 @@ export class PlaylistsCommand extends AbstractCommand {
43 start?: number 44 start?: number
44 count?: number 45 count?: number
45 sort?: string 46 sort?: string
47 playlistType?: VideoPlaylistType
46 }) { 48 }) {
47 const path = '/api/v1/video-channels/' + options.handle + '/video-playlists' 49 const path = '/api/v1/video-channels/' + options.handle + '/video-playlists'
48 const query = pick(options, [ 'start', 'count', 'sort' ]) 50 const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ])
49 51
50 return this.getRequestBody<ResultList<VideoPlaylist>>({ 52 return this.getRequestBody<ResultList<VideoPlaylist>>({
51 ...options, 53 ...options,
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index fa50e8f17..d9e91c131 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -3801,6 +3801,34 @@ paths:
3801 schema: 3801 schema:
3802 $ref: '#/components/schemas/VideoListResponse' 3802 $ref: '#/components/schemas/VideoListResponse'
3803 3803
3804 '/api/v1/video-channels/{channelHandle}/video-playlists':
3805 get:
3806 summary: List playlists of a channel
3807 tags:
3808 - Video Playlists
3809 - Video Channels
3810 parameters:
3811 - $ref: '#/components/parameters/channelHandle'
3812 - $ref: '#/components/parameters/start'
3813 - $ref: '#/components/parameters/count'
3814 - $ref: '#/components/parameters/sort'
3815 - $ref: '#/components/parameters/videoPlaylistType'
3816 responses:
3817 '200':
3818 description: successful operation
3819 content:
3820 application/json:
3821 schema:
3822 type: object
3823 properties:
3824 total:
3825 type: integer
3826 example: 1
3827 data:
3828 type: array
3829 items:
3830 $ref: '#/components/schemas/VideoPlaylist'
3831
3804 '/api/v1/video-channels/{channelHandle}/followers': 3832 '/api/v1/video-channels/{channelHandle}/followers':
3805 get: 3833 get:
3806 tags: 3834 tags:
@@ -4045,6 +4073,7 @@ paths:
4045 - $ref: '#/components/parameters/start' 4073 - $ref: '#/components/parameters/start'
4046 - $ref: '#/components/parameters/count' 4074 - $ref: '#/components/parameters/count'
4047 - $ref: '#/components/parameters/sort' 4075 - $ref: '#/components/parameters/sort'
4076 - $ref: '#/components/parameters/videoPlaylistType'
4048 responses: 4077 responses:
4049 '200': 4078 '200':
4050 description: successful operation 4079 description: successful operation
@@ -4361,7 +4390,35 @@ paths:
4361 format: seconds 4390 format: seconds
4362 stopTimestamp: 4391 stopTimestamp:
4363 type: integer 4392 type: integer
4364 format: seconds 4393
4394 '/api/v1/accounts/{name}/video-playlists':
4395 get:
4396 summary: List playlists of an account
4397 tags:
4398 - Video Playlists
4399 - Accounts
4400 parameters:
4401 - $ref: '#/components/parameters/name'
4402 - $ref: '#/components/parameters/start'
4403 - $ref: '#/components/parameters/count'
4404 - $ref: '#/components/parameters/sort'
4405 - $ref: '#/components/parameters/search'
4406 - $ref: '#/components/parameters/videoPlaylistType'
4407 responses:
4408 '200':
4409 description: successful operation
4410 content:
4411 application/json:
4412 schema:
4413 type: object
4414 properties:
4415 total:
4416 type: integer
4417 example: 1
4418 data:
4419 type: array
4420 items:
4421 $ref: '#/components/schemas/VideoPlaylist'
4365 4422
4366 '/api/v1/accounts/{name}/video-channels': 4423 '/api/v1/accounts/{name}/video-channels':
4367 get: 4424 get:
@@ -5920,7 +5977,13 @@ components:
5920 description: Ask the server to reinject videoFileToken in URLs in m3u8 playlist 5977 description: Ask the server to reinject videoFileToken in URLs in m3u8 playlist
5921 schema: 5978 schema:
5922 type: boolean 5979 type: boolean
5923 5980 videoPlaylistType:
5981 name: playlistType
5982 in: query
5983 required: false
5984 schema:
5985 $ref: '#/components/schemas/VideoPlaylistTypeSet'
5986
5924 securitySchemes: 5987 securitySchemes:
5925 OAuth2: 5988 OAuth2:
5926 description: | 5989 description: |