+ if (video.privacy !== VideoPrivacy.PUBLIC) {
+ return res.status(HttpStatusCode.FORBIDDEN_403)
+ .json({ error: 'Video is not public' })
+ }
+
+ res.locals.videoAll = video
+ return next()
+ }
+
+ // Is playlist
+
+ const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannelSummary(elementId, undefined)
+ if (!videoPlaylist) {
+ return res.status(HttpStatusCode.NOT_FOUND_404)
+ .json({ error: 'Video playlist not found' })
+ }
+
+ if (videoPlaylist.privacy !== VideoPlaylistPrivacy.PUBLIC) {
+ return res.status(HttpStatusCode.FORBIDDEN_403)
+ .json({ error: 'Playlist is not public' })
+ }
+
+ res.locals.videoPlaylistSummary = videoPlaylist