From cbc4020c2ee9e67acf54c68595f9c4d83715e044 Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Tue, 6 Aug 2024 17:45:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Makes=20youtubedl=20works?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/Commands/Youtubedl.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bot/Commands/Youtubedl.php b/bot/Commands/Youtubedl.php index e589dde..ae973da 100644 --- a/bot/Commands/Youtubedl.php +++ b/bot/Commands/Youtubedl.php @@ -27,26 +27,21 @@ class Youtubedl implements Icommands if (in_array($type, ['', 'audio'], true)) { $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]); -// $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 { $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]); -// $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(); -// executes after the command finishes if (!$process->isSuccessful()) { $ex = new ProcessFailedException($process); $bot->reply($ex->getMessage()); + return; } $bot->reply($process->getOutput()); -// $bot->replyPolitely(sprintf('Je %s %s', $action, $type)); } public static function getDescription(): string