{
$ext = $onlyAudio ? 'mp3' : 'mp4';
- $cli = new CommandLine('/usr/local/bin/yt-dlp');
- $cli->setArg('cache-dir', storage_path('cache/youtubedl'));
+ $cli = static::_getCli();
$cli->setArg('format', $format);
$cli->setArg('extractor-args', 'youtube:player_client=web,default,-ios');
if ($onlyAudio) {
$cli->setArg('audio-format', 'mp3');
$cli->setArg('audio-quality', '0');
}
- if (null !== static::$_cookiesFile) {
- $cli->setArg('cookies', static::$_cookiesFile);
- }
-
$cacheKey = hash('sha256', $url . "-" . $cli->hashArgs());
$fname = $cacheKey . '.' . $ext;
$file = Files::mkdir($path) . $fname;
}
if (!file_exists($file)) {
$cli->debug();
+
+
+ $cli = static::_getCli();
+ $cli->setArg('list-formats');
+ $cli->setArg(null, $url);
+ $cli->execute();
+ $cli->debug();
}
return $file;
}
+
+ /**
+ * @return CommandLine
+ */
+ protected static function _getCli()
+ {
+ $cli = new CommandLine('/usr/local/bin/yt-dlp');
+ $cli->setArg('cache-dir', storage_path('cache/youtubedl'));
+ if (null !== static::$_cookiesFile) {
+ $cli->setArg('cookies', static::$_cookiesFile);
+ }
+ return $cli;
+
+ }
}
\ No newline at end of file