From d39fd063877e807eeab55fc61b24bd5303a2b6bc Mon Sep 17 00:00:00 2001 From: mikhail Date: Wed, 22 May 2024 22:56:47 +0500 Subject: [PATCH] fix: video length check in nicovideo --- src/modules/processing/services/nicovideo.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/processing/services/nicovideo.js b/src/modules/processing/services/nicovideo.js index 1cd22f9c..9548581d 100644 --- a/src/modules/processing/services/nicovideo.js +++ b/src/modules/processing/services/nicovideo.js @@ -1,4 +1,4 @@ -import { genericUserAgent } from "../../config.js"; +import { env, genericUserAgent } from "../../config.js"; import { cleanString } from "../../sub/utils.js"; import HLS from "hls-parser"; import util from "node:util"; @@ -144,7 +144,12 @@ async function getHLSContent(contentURL, quality, isAudioOnly) { export default async function nicovideo({ id, quality, isAudioOnly }) { try { - const { actionTrackId, title, author } = await getBasicVideoInformation(id); + const { actionTrackId, title, author, lengthInSeconds } = await getBasicVideoInformation(id); + + if (lengthInSeconds > env.durationLimit) { + throw new CobaltError(['ErrorLengthLimit', env.durationLimit / 60]); + } + const { resolution, urls, type } = await fetchGuestData(id, actionTrackId) .then(({ accessRightKey, outputs }) => fetchContentURL(id, actionTrackId, accessRightKey, outputs)