From: Vincent Vanwaelscappel Date: Fri, 5 May 2023 14:05:22 +0000 (+0200) Subject: wip #5919 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ca1037d83729b014940437588b89ea0d87ffeba6;p=cubist_util.git wip #5919 @0.25 --- diff --git a/src/YoutubeDL.php b/src/YoutubeDL.php index 36f3980..181e972 100644 --- a/src/YoutubeDL.php +++ b/src/YoutubeDL.php @@ -3,7 +3,7 @@ namespace Cubist\Util; use Cubist\Util\Files\Files; -use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; use YoutubeDl\Options; class YoutubeDL @@ -27,25 +27,24 @@ class YoutubeDL ->cacheDir(storage_path('cache/youtubedl')) ->format('bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4') ->url($url); - + if ($onlyAudio) { $ext = 'mp3'; - $options->extractAudio(true) + $options = $options->extractAudio(true) ->audioFormat('mp3'); } - $cacheKey = hash('sha256', $url . print_r($options->toArray(), true)); $fname = $cacheKey . '.' . $ext; $file = Files::mkdir($path) . $fname; - $options->output($fname); + $options = $options->output($fname); if (!file_exists($file)) { $yt = new \YoutubeDl\YoutubeDl(); + $yt->setBinPath('/usr/local/bin/yt-dlp'); $yt->download($options); } - return $file; } } \ No newline at end of file