fixed bugs introduced in a5c3785ed8d6a35868bc169f07e40e889087fd2e

This commit is contained in:
huangjx
2021-10-05 10:26:23 +08:00
parent 6e8b607dd9
commit 118ff8ec31
2 changed files with 12 additions and 3 deletions

View File

@@ -37,13 +37,17 @@ class Aria2
); );
//turn keys in $options into variables //turn keys in $options into variables
extract($options); extract($options);
if (isset($binary) && @is_executable($binary)) {
$this->bin = $binary;
} else {
$this->bin = Helper::findBinaryPath('aria2c');
}
$this->setDownloadDir($dir); $this->setDownloadDir($dir);
if (!empty($settings)) { if (!empty($settings)) {
foreach ($settings as $key => $value) { foreach ($settings as $key => $value) {
$this->setOption($key, $value); $this->setOption($key, $value);
} }
} }
$this->bin = Helper::findBinaryPath('aria2c');
$this->php = Helper::findBinaryPath('php'); $this->php = Helper::findBinaryPath('php');
$this->completeHook = $completeHook; $this->completeHook = $completeHook;
$this->rpcUrl = sprintf("http://%s:%s/jsonrpc", $host, $port); $this->rpcUrl = sprintf("http://%s:%s/jsonrpc", $host, $port);

View File

@@ -14,7 +14,7 @@ class Youtube
private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'; private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best';
private $options = []; private $options = [];
private $downloadDir; 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 $outTpl = "/%(id)s-%(title)s.%(ext)s";
private $defaultDir = "/tmp/downloads"; private $defaultDir = "/tmp/downloads";
private $env = []; private $env = [];
@@ -26,8 +26,13 @@ class Youtube
} }
public function init(array $options) public function init(array $options)
{ {
$this->bin = Helper::findBinaryPath('youtube-dl');
extract($options); extract($options);
if (isset($binary) && @is_executable($binary)) {
$this->bin = $binary;
} else {
$this->bin = Helper::findBinaryPath('youtube-dl');
}
$this->setDownloadDir($downloadDir); $this->setDownloadDir($downloadDir);
if (!empty($settings)) { if (!empty($settings)) {
foreach ($settings as $key => $value) { foreach ($settings as $key => $value) {