🐛 Trying to debug with Process
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Shikiryu\Bot\Commands;
|
||||
|
||||
use Shikiryu\Bot\Bot;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class Youtubedl implements Icommands
|
||||
{
|
||||
@@ -24,16 +26,27 @@ class Youtubedl implements Icommands
|
||||
|
||||
if (in_array($type, ['', 'audio'], true)) {
|
||||
$type = 'l\'audio';
|
||||
$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));
|
||||
$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';
|
||||
$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));
|
||||
$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());
|
||||
}
|
||||
|
||||
$bot->reply($process->getOutput());
|
||||
// $bot->replyPolitely(sprintf('Je %s %s', $action, $type));
|
||||
}
|
||||
|
||||
public static function getDescription(): string
|
||||
@@ -54,7 +67,7 @@ class Youtubedl implements Icommands
|
||||
|
||||
private static function getDownloadFolder(Bot $bot): string
|
||||
{
|
||||
return $bot->getConfig()['youtube-dl']['folder'] ?? __DIR__.'/../../';
|
||||
return $bot->getConfig()['youtube-dl']['download_folder'] ?? __DIR__.'/../../';
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user