diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-26 10:55:40 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (patch) | |
tree | 5e9bc5604fd5d66a006cfebb7acdbdd5486e5d1e /server/controllers/api/video-channel.ts | |
parent | b427febb4d5cebf03b815bca2c59af6e82491569 (diff) | |
download | PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.gz PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.zst PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.zip |
Playlist server API
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index db7602139..534cc8d7b 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -12,7 +12,8 @@ import { | |||
12 | videoChannelsAddValidator, | 12 | videoChannelsAddValidator, |
13 | videoChannelsRemoveValidator, | 13 | videoChannelsRemoveValidator, |
14 | videoChannelsSortValidator, | 14 | videoChannelsSortValidator, |
15 | videoChannelsUpdateValidator | 15 | videoChannelsUpdateValidator, |
16 | videoPlaylistsSortValidator | ||
16 | } from '../../middlewares' | 17 | } from '../../middlewares' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | 18 | import { VideoChannelModel } from '../../models/video/video-channel' |
18 | import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' | 19 | import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' |
@@ -31,6 +32,7 @@ import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '.. | |||
31 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 32 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
32 | import { UserModel } from '../../models/account/user' | 33 | import { UserModel } from '../../models/account/user' |
33 | import { JobQueue } from '../../lib/job-queue' | 34 | import { JobQueue } from '../../lib/job-queue' |
35 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | ||
34 | 36 | ||
35 | const auditLogger = auditLoggerFactory('channels') | 37 | const auditLogger = auditLoggerFactory('channels') |
36 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 38 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) |
@@ -77,6 +79,15 @@ videoChannelRouter.get('/:nameWithHost', | |||
77 | asyncMiddleware(getVideoChannel) | 79 | asyncMiddleware(getVideoChannel) |
78 | ) | 80 | ) |
79 | 81 | ||
82 | videoChannelRouter.get('/:nameWithHost/video-playlists', | ||
83 | asyncMiddleware(videoChannelsNameWithHostValidator), | ||
84 | paginationValidator, | ||
85 | videoPlaylistsSortValidator, | ||
86 | setDefaultSort, | ||
87 | setDefaultPagination, | ||
88 | asyncMiddleware(listVideoChannelPlaylists) | ||
89 | ) | ||
90 | |||
80 | videoChannelRouter.get('/:nameWithHost/videos', | 91 | videoChannelRouter.get('/:nameWithHost/videos', |
81 | asyncMiddleware(videoChannelsNameWithHostValidator), | 92 | asyncMiddleware(videoChannelsNameWithHostValidator), |
82 | paginationValidator, | 93 | paginationValidator, |
@@ -206,6 +217,20 @@ async function getVideoChannel (req: express.Request, res: express.Response, nex | |||
206 | return res.json(videoChannelWithVideos.toFormattedJSON()) | 217 | return res.json(videoChannelWithVideos.toFormattedJSON()) |
207 | } | 218 | } |
208 | 219 | ||
220 | async function listVideoChannelPlaylists (req: express.Request, res: express.Response) { | ||
221 | const serverActor = await getServerActor() | ||
222 | |||
223 | const resultList = await VideoPlaylistModel.listForApi({ | ||
224 | followerActorId: serverActor.id, | ||
225 | start: req.query.start, | ||
226 | count: req.query.count, | ||
227 | sort: req.query.sort, | ||
228 | videoChannelId: res.locals.videoChannel.id | ||
229 | }) | ||
230 | |||
231 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | ||
232 | } | ||
233 | |||
209 | async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 234 | async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { |
210 | const videoChannelInstance: VideoChannelModel = res.locals.videoChannel | 235 | const videoChannelInstance: VideoChannelModel = res.locals.videoChannel |
211 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined | 236 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined |