class YoutubeDL
{
+ protected static $_cookiesFile = null;
+
+ public static function setCookiesFile($cookieFile)
+ {
+ static::$_cookiesFile = $cookieFile;
+ }
+
public static function downloadVideo($url, $path)
{
return self::_download($url, $path);
->format('bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4')
->url($url);
+ if (null !== static::$_cookiesFile) {
+ $options = $options->cookies(static::$_cookiesFile);
+ }
+
if ($onlyAudio) {
$ext = 'mp3';
$options = $options->extractAudio(true)
if (!file_exists($file)) {
$yt = new \YoutubeDl\YoutubeDl();
$yt->setBinPath('/usr/local/bin/yt-dlp');
- $yt->download($options);
+ $collection = $yt->download($options);
+
+ foreach ($collection->getVideos() as $video) {
+ if ($video->getError() !== null) {
+ Log::debug("Error downloading video: {$video->getError()}.");
+ } else {
+ $video->getFile();
+ }
+ }
+
}
return $file;
}