- const playlist = getHLSPlaylist(video)
- if (!playlist) return res.status(HttpStatusCode.NOT_FOUND_404).end
+ const streamingPlaylist = getHLSPlaylist(video)
+ if (!streamingPlaylist) return res.status(HttpStatusCode.NOT_FOUND_404).end
+
+ const videoFile = getVideoFile(req, streamingPlaylist.VideoFiles)
+ if (!videoFile) {
+ return res.fail({
+ status: HttpStatusCode.NOT_FOUND_404,
+ message: 'Video file not found'
+ })
+ }
+
+ const allowParameters = { video, streamingPlaylist, videoFile }
+
+ const allowedResult = await Hooks.wrapFun(
+ isVideoDownloadAllowed,
+ allowParameters,
+ 'filter:api.download.video.allowed.result'
+ )
+
+ if (!checkAllowResult(res, allowParameters, allowedResult)) return