Fix filters on playlists
This commit is contained in:
parent
918ba713e4
commit
16ccb43767
|
@ -139,7 +139,7 @@ async function listVideoPlaylists (req: express.Request, res: express.Response)
|
||||||
start: req.query.start,
|
start: req.query.start,
|
||||||
count: req.query.count,
|
count: req.query.count,
|
||||||
sort: req.query.sort,
|
sort: req.query.sort,
|
||||||
type: req.query.type
|
type: req.query.playlistType
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||||
|
|
|
@ -142,7 +142,7 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
|
||||||
|
|
||||||
const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary
|
const videoPlaylist = res.locals.videoPlaylistFull || res.locals.videoPlaylistSummary
|
||||||
|
|
||||||
// Video is unlisted, check we used the uuid to fetch it
|
// Playlist is unlisted, check we used the uuid to fetch it
|
||||||
if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) {
|
if (videoPlaylist.privacy === VideoPlaylistPrivacy.UNLISTED) {
|
||||||
if (isUUIDValid(req.params.playlistId)) return next()
|
if (isUUIDValid(req.params.playlistId)) return next()
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ describe('Test video playlists', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Get default playlists', function () {
|
describe('Check playlists filters and privacies', function () {
|
||||||
|
|
||||||
it('Should list video playlist privacies', async function () {
|
it('Should list video playlist privacies', async function () {
|
||||||
const privacies = await commands[0].getPrivacies()
|
const privacies = await commands[0].getPrivacies()
|
||||||
|
@ -123,9 +123,21 @@ describe('Test video playlists', function () {
|
||||||
expect(privacies[3]).to.equal('Private')
|
expect(privacies[3]).to.equal('Private')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should list watch later playlist', async function () {
|
it('Should filter on playlist type', async function () {
|
||||||
|
this.timeout(30000)
|
||||||
|
|
||||||
const token = servers[0].accessToken
|
const token = servers[0].accessToken
|
||||||
|
|
||||||
|
await commands[0].create({
|
||||||
|
attributes: {
|
||||||
|
displayName: 'my super playlist',
|
||||||
|
privacy: VideoPlaylistPrivacy.PUBLIC,
|
||||||
|
description: 'my super description',
|
||||||
|
thumbnailfile: 'thumbnail.jpg',
|
||||||
|
videoChannelId: servers[0].store.channel.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
{
|
{
|
||||||
const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER })
|
const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.WATCH_LATER })
|
||||||
|
|
||||||
|
@ -136,14 +148,52 @@ describe('Test video playlists', function () {
|
||||||
expect(playlist.displayName).to.equal('Watch later')
|
expect(playlist.displayName).to.equal('Watch later')
|
||||||
expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
|
expect(playlist.type.id).to.equal(VideoPlaylistType.WATCH_LATER)
|
||||||
expect(playlist.type.label).to.equal('Watch later')
|
expect(playlist.type.label).to.equal('Watch later')
|
||||||
|
expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const body = await commands[0].listByAccount({ token, handle: 'root', playlistType: VideoPlaylistType.REGULAR })
|
const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.WATCH_LATER })
|
||||||
|
const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.WATCH_LATER })
|
||||||
|
|
||||||
|
for (const body of [ bodyList, bodyChannel ]) {
|
||||||
expect(body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
|
||||||
|
const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
|
||||||
|
|
||||||
|
let playlist: VideoPlaylist = null
|
||||||
|
for (const body of [ bodyList, bodyChannel ]) {
|
||||||
|
|
||||||
|
expect(body.total).to.equal(1)
|
||||||
|
expect(body.data).to.have.lengthOf(1)
|
||||||
|
|
||||||
|
playlist = body.data[0]
|
||||||
|
expect(playlist.displayName).to.equal('my super playlist')
|
||||||
|
expect(playlist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
|
||||||
|
expect(playlist.type.id).to.equal(VideoPlaylistType.REGULAR)
|
||||||
|
}
|
||||||
|
|
||||||
|
await commands[0].update({
|
||||||
|
playlistId: playlist.id,
|
||||||
|
attributes: {
|
||||||
|
privacy: VideoPlaylistPrivacy.PRIVATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const bodyList = await commands[0].list({ playlistType: VideoPlaylistType.REGULAR })
|
||||||
|
const bodyChannel = await commands[0].listByChannel({ handle: 'root_channel', playlistType: VideoPlaylistType.REGULAR })
|
||||||
|
|
||||||
|
for (const body of [ bodyList, bodyChannel ]) {
|
||||||
|
expect(body.total).to.equal(0)
|
||||||
|
expect(body.data).to.have.lengthOf(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const body = await commands[0].listByAccount({ handle: 'root' })
|
const body = await commands[0].listByAccount({ handle: 'root' })
|
||||||
|
|
|
@ -24,9 +24,10 @@ export class PlaylistsCommand extends AbstractCommand {
|
||||||
start?: number
|
start?: number
|
||||||
count?: number
|
count?: number
|
||||||
sort?: string
|
sort?: string
|
||||||
|
playlistType?: VideoPlaylistType
|
||||||
}) {
|
}) {
|
||||||
const path = '/api/v1/video-playlists'
|
const path = '/api/v1/video-playlists'
|
||||||
const query = pick(options, [ 'start', 'count', 'sort' ])
|
const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ])
|
||||||
|
|
||||||
return this.getRequestBody<ResultList<VideoPlaylist>>({
|
return this.getRequestBody<ResultList<VideoPlaylist>>({
|
||||||
...options,
|
...options,
|
||||||
|
@ -43,9 +44,10 @@ export class PlaylistsCommand extends AbstractCommand {
|
||||||
start?: number
|
start?: number
|
||||||
count?: number
|
count?: number
|
||||||
sort?: string
|
sort?: string
|
||||||
|
playlistType?: VideoPlaylistType
|
||||||
}) {
|
}) {
|
||||||
const path = '/api/v1/video-channels/' + options.handle + '/video-playlists'
|
const path = '/api/v1/video-channels/' + options.handle + '/video-playlists'
|
||||||
const query = pick(options, [ 'start', 'count', 'sort' ])
|
const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ])
|
||||||
|
|
||||||
return this.getRequestBody<ResultList<VideoPlaylist>>({
|
return this.getRequestBody<ResultList<VideoPlaylist>>({
|
||||||
...options,
|
...options,
|
||||||
|
|
|
@ -3801,6 +3801,34 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/VideoListResponse'
|
$ref: '#/components/schemas/VideoListResponse'
|
||||||
|
|
||||||
|
'/api/v1/video-channels/{channelHandle}/video-playlists':
|
||||||
|
get:
|
||||||
|
summary: List playlists of a channel
|
||||||
|
tags:
|
||||||
|
- Video Playlists
|
||||||
|
- Video Channels
|
||||||
|
parameters:
|
||||||
|
- $ref: '#/components/parameters/channelHandle'
|
||||||
|
- $ref: '#/components/parameters/start'
|
||||||
|
- $ref: '#/components/parameters/count'
|
||||||
|
- $ref: '#/components/parameters/sort'
|
||||||
|
- $ref: '#/components/parameters/videoPlaylistType'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
total:
|
||||||
|
type: integer
|
||||||
|
example: 1
|
||||||
|
data:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/VideoPlaylist'
|
||||||
|
|
||||||
'/api/v1/video-channels/{channelHandle}/followers':
|
'/api/v1/video-channels/{channelHandle}/followers':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
@ -4045,6 +4073,7 @@ paths:
|
||||||
- $ref: '#/components/parameters/start'
|
- $ref: '#/components/parameters/start'
|
||||||
- $ref: '#/components/parameters/count'
|
- $ref: '#/components/parameters/count'
|
||||||
- $ref: '#/components/parameters/sort'
|
- $ref: '#/components/parameters/sort'
|
||||||
|
- $ref: '#/components/parameters/videoPlaylistType'
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: successful operation
|
description: successful operation
|
||||||
|
@ -4361,7 +4390,35 @@ paths:
|
||||||
format: seconds
|
format: seconds
|
||||||
stopTimestamp:
|
stopTimestamp:
|
||||||
type: integer
|
type: integer
|
||||||
format: seconds
|
|
||||||
|
'/api/v1/accounts/{name}/video-playlists':
|
||||||
|
get:
|
||||||
|
summary: List playlists of an account
|
||||||
|
tags:
|
||||||
|
- Video Playlists
|
||||||
|
- Accounts
|
||||||
|
parameters:
|
||||||
|
- $ref: '#/components/parameters/name'
|
||||||
|
- $ref: '#/components/parameters/start'
|
||||||
|
- $ref: '#/components/parameters/count'
|
||||||
|
- $ref: '#/components/parameters/sort'
|
||||||
|
- $ref: '#/components/parameters/search'
|
||||||
|
- $ref: '#/components/parameters/videoPlaylistType'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
total:
|
||||||
|
type: integer
|
||||||
|
example: 1
|
||||||
|
data:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/VideoPlaylist'
|
||||||
|
|
||||||
'/api/v1/accounts/{name}/video-channels':
|
'/api/v1/accounts/{name}/video-channels':
|
||||||
get:
|
get:
|
||||||
|
@ -5920,6 +5977,12 @@ components:
|
||||||
description: Ask the server to reinject videoFileToken in URLs in m3u8 playlist
|
description: Ask the server to reinject videoFileToken in URLs in m3u8 playlist
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
videoPlaylistType:
|
||||||
|
name: playlistType
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VideoPlaylistTypeSet'
|
||||||
|
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
OAuth2:
|
OAuth2:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user