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;