From 3d39af7a9818f773a1a78e373336a12544eb23c1 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 4 Nov 2024 18:51:54 +0100 Subject: [PATCH] fix(download): improve stream selection logic Added a check to ensure remux stream is selected only when there are multiple video URLs and no 'entries' in the video object. This prevents unnecessary remuxing when entries exist, optimizing resource usage and maintaining proper stream handling. --- classes/Controller/DownloadController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/Controller/DownloadController.php b/classes/Controller/DownloadController.php index daf0f15..c1b43e0 100644 --- a/classes/Controller/DownloadController.php +++ b/classes/Controller/DownloadController.php @@ -112,6 +112,8 @@ class DownloadController extends BaseController $to = $request->getQueryParam('to'); } + assert((is_string($from) || is_null($from)) && (is_string($to) || is_null($to))); + $response = $response->withHeader( 'Content-Disposition', 'attachment; filename="' . @@ -281,7 +283,7 @@ class DownloadController extends BaseController */ $videoUrls = []; } - if (count($videoUrls) > 1) { + if (count($videoUrls) > 1 && !isset($this->video->entries)) { return $this->getRemuxStream($request, $response); } elseif ($this->config->stream && (isset($this->video->entries) || $request->getQueryParam('stream'))) { return $this->getStream($request, $response); @@ -311,6 +313,9 @@ class DownloadController extends BaseController */ private function getConvertedResponse(Request $request, Response $response): Response { + assert(is_string($request->getQueryParam('customFormat'))); + assert(is_int($request->getQueryParam('customBitrate'))); + $response = $response->withHeader( 'Content-Disposition', 'attachment; filename="' .