From 118ff8ec318fc885a6354fcd98becddefa6df0d5 Mon Sep 17 00:00:00 2001 From: huangjx Date: Tue, 5 Oct 2021 10:26:23 +0800 Subject: [PATCH] fixed bugs introduced in a5c3785ed8d6a35868bc169f07e40e889087fd2e --- lib/Tools/Aria2.php | 6 +++++- lib/Tools/Youtube.php | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Tools/Aria2.php b/lib/Tools/Aria2.php index 24d2ae2..7301a49 100644 --- a/lib/Tools/Aria2.php +++ b/lib/Tools/Aria2.php @@ -37,13 +37,17 @@ class Aria2 ); //turn keys in $options into variables extract($options); + if (isset($binary) && @is_executable($binary)) { + $this->bin = $binary; + } else { + $this->bin = Helper::findBinaryPath('aria2c'); + } $this->setDownloadDir($dir); if (!empty($settings)) { foreach ($settings as $key => $value) { $this->setOption($key, $value); } } - $this->bin = Helper::findBinaryPath('aria2c'); $this->php = Helper::findBinaryPath('php'); $this->completeHook = $completeHook; $this->rpcUrl = sprintf("http://%s:%s/jsonrpc", $host, $port); diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php index dc8f484..0baff4a 100644 --- a/lib/Tools/Youtube.php +++ b/lib/Tools/Youtube.php @@ -14,7 +14,7 @@ class Youtube private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'; private $options = []; private $downloadDir; - private $timeout = 60 * 60 * 3;//3 hours + private $timeout = 60 * 60 * 3; //3 hours private $outTpl = "/%(id)s-%(title)s.%(ext)s"; private $defaultDir = "/tmp/downloads"; private $env = []; @@ -26,8 +26,13 @@ class Youtube } public function init(array $options) { - $this->bin = Helper::findBinaryPath('youtube-dl'); extract($options); + if (isset($binary) && @is_executable($binary)) { + $this->bin = $binary; + } else { + $this->bin = Helper::findBinaryPath('youtube-dl'); + } + $this->setDownloadDir($downloadDir); if (!empty($settings)) { foreach ($settings as $key => $value) {