namespace Cubist\Util;
use Cubist\Util\Files\Files;
-use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Log;
use YoutubeDl\Options;
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