From 13671d8794946b7ea0bc02899e6d94595730647c Mon Sep 17 00:00:00 2001 From: tree1891 Date: Wed, 20 Nov 2024 18:00:40 +0800 Subject: [PATCH] fix: fileName info missing --- src/YoutubeDl.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/YoutubeDl.php b/src/YoutubeDl.php index 5323209..041fbec 100644 --- a/src/YoutubeDl.php +++ b/src/YoutubeDl.php @@ -140,18 +140,26 @@ public function download(Options $options): VideoCollection $currentVideo['extractor'] = $match['extractor']; $currentVideo['id'] = $match['id']; - } elseif (preg_match('/\[download] File is (larger|smaller) than (min|max)-filesize/', $buffer, $match) === 1) { + } + + if (preg_match('/\[download] File is (larger|smaller) than (min|max)-filesize/', $buffer, $match) === 1) { $currentVideo['error'] = trim(substr($buffer, 11)); } elseif (str_starts_with($buffer, 'ERROR:')) { $currentVideo['error'] = trim(substr($buffer, 6)); - } elseif (preg_match('/Writing video( description)? metadata as JSON to:\s(?.+)/', $buffer, $match) === 1) { + } + + if (preg_match('/Writing video( description)? metadata as JSON to:\s(?.+)/', $buffer, $match) === 1) { $currentVideo['metadataFile'] = $match['metadataFile']; - } elseif (preg_match('/\[(ffmpeg|Merger)] Merging formats into "(?.+)"/', $buffer, $match) === 1) { + } + + if (preg_match('/\[(ffmpeg|Merger)] Merging formats into "(?.+)"/', $buffer, $match) === 1) { $currentVideo['fileName'] = $match['file']; } elseif (preg_match('/\[(download|ffmpeg|ExtractAudio)] Destination: (?.+)/', $buffer, $match) === 1 || preg_match('/\[download] (?.+) has already been downloaded/', $buffer, $match) === 1) { $currentVideo['fileName'] = $match['file']; $progressTarget = basename($match['file']); - } elseif (preg_match_all(static::PROGRESS_PATTERN, $buffer, $matches, PREG_SET_ORDER) !== false) { + } + + if (preg_match_all(static::PROGRESS_PATTERN, $buffer, $matches, PREG_SET_ORDER) !== false) { if (count($matches) > 0) { $progress = $this->progress;