🐛 Makes youtubedl works

This commit is contained in:
Clement Desmidt 2024-08-06 17:45:59 +02:00
parent a4a678d32f
commit cbc4020c2e

View File

@ -27,26 +27,21 @@ class Youtubedl implements Icommands
if (in_array($type, ['', 'audio'], true)) { if (in_array($type, ['', 'audio'], true)) {
$type = 'l\'audio'; $type = 'l\'audio';
$process = new Process([$youtubedl, '--extract-audio', '--audio-format', 'mp3', sprintf('-o %s%s', static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s'), $url]); $process = new Process([$youtubedl, '--extract-audio', '--audio-format', 'mp3', sprintf('-o %s%s', static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s'), $url]);
// $cmd = sprintf('%s --extract-audio --audio-format mp3 -o %s%s %s', $youtubedl, static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s', $url);
// exec($cmd, $output);
// $bot->sendChatMessage('', sprintf('Je lance %s', $cmd));
} else { } else {
$type = 'la vidéo'; $type = 'la vidéo';
$process = new Process([$youtubedl, '-f bestvideo+bestaudio/best', sprintf('-o %s%s', static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s'), $url]); $process = new Process([$youtubedl, '-f bestvideo+bestaudio/best', sprintf('-o %s%s', static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s'), $url]);
// $cmd = sprintf('%s -f bestvideo+bestaudio/best -o %s%s %s', $youtubedl, static::getDownloadFolder($bot), '%(upload_date)s-%(uploader)s-%(title)s.%(ext)s', $url);
// exec($cmd, $output);
// $bot->sendChatMessage('', sprintf('Je lance %s', $cmd));
} }
$bot->replyPolitely(sprintf('Je %s %s', $action, $type));
$process->run(); $process->run();
// executes after the command finishes
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
$ex = new ProcessFailedException($process); $ex = new ProcessFailedException($process);
$bot->reply($ex->getMessage()); $bot->reply($ex->getMessage());
return;
} }
$bot->reply($process->getOutput()); $bot->reply($process->getOutput());
// $bot->replyPolitely(sprintf('Je %s %s', $action, $type));
} }
public static function getDescription(): string public static function getDescription(): string