]> _ Git - cubist_util.git/commitdiff
wip #5919 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 May 2023 14:05:22 +0000 (16:05 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 May 2023 14:05:22 +0000 (16:05 +0200)
src/YoutubeDL.php

index 36f3980269f6af7de074c0c43ac4274936b10b3a..181e97275b9e3ebdd3ba307550c6bb7d99d0052c 100644 (file)
@@ -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