improved user experience for novice user(including support for standalone aria2c and ytdl binaries);support for snap installation;close #19
This commit is contained in:
@@ -38,10 +38,10 @@ class Aria2
|
||||
);
|
||||
//turn keys in $options into variables
|
||||
extract($options);
|
||||
if (isset($binary) && @is_executable($binary)) {
|
||||
if (isset($binary) && $this->isExecutable($binary)) {
|
||||
$this->bin = $binary;
|
||||
} else {
|
||||
$this->bin = Helper::findBinaryPath('aria2c');
|
||||
$this->bin = Helper::findBinaryPath('aria2c', __DIR__ . "/../../bin/aria2c");
|
||||
}
|
||||
$this->setDownloadDir($dir);
|
||||
$this->setTorrentsDir($torrents_dir);
|
||||
@@ -379,17 +379,27 @@ class Aria2
|
||||
}
|
||||
public function isInstalled()
|
||||
{
|
||||
return (bool) (isset($this->bin) && @is_executable($this->bin));
|
||||
return @is_file($this->bin);
|
||||
}
|
||||
public function isExecutable()
|
||||
{
|
||||
return @is_executable($this->bin);
|
||||
}
|
||||
|
||||
public function isRunning()
|
||||
{
|
||||
$resp = $this->getSessionInfo();
|
||||
return (bool) $resp;
|
||||
}
|
||||
|
||||
public function getBin()
|
||||
{
|
||||
return $this->bin;
|
||||
}
|
||||
public function stop()
|
||||
{
|
||||
$resp = $this->shutdown();
|
||||
sleep(1);
|
||||
sleep(3);
|
||||
return $resp ?? null;
|
||||
}
|
||||
private function confTemplate()
|
||||
|
||||
@@ -202,6 +202,7 @@ class Helper
|
||||
if ($memcache->hasKey($program)) {
|
||||
return $memcache->get($program);
|
||||
}
|
||||
|
||||
$dataPath = \OC::$server->getSystemConfig()->getValue('datadirectory');
|
||||
$paths = ['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/opt/bin', $dataPath . "/bin"];
|
||||
$result = $default;
|
||||
|
||||
@@ -18,6 +18,7 @@ class Youtube
|
||||
private $outTpl = "%(id)s-%(title).64s.%(ext)s";
|
||||
private $defaultDir = "/tmp/downloads";
|
||||
private $env = [];
|
||||
private $bin;
|
||||
|
||||
public function __construct(array $options)
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class Youtube
|
||||
public function init(array $options)
|
||||
{
|
||||
extract($options);
|
||||
if (isset($binary) && @is_executable($binary)) {
|
||||
if (isset($binary) && $this->isExecutable($binary)) {
|
||||
$this->bin = $binary;
|
||||
} else {
|
||||
$this->bin = Helper::findBinaryPath('youtube-dl', __DIR__ . "/../../bin/youtube-dl");
|
||||
@@ -157,7 +158,7 @@ class Youtube
|
||||
$data = ['link' => $url];
|
||||
$process->run(function ($type, $buffer) use ($data, $process) {
|
||||
if (Process::ERR === $type) {
|
||||
// $this->onError($buffer);
|
||||
// $this->onError($buffer);
|
||||
} else {
|
||||
$data['pid'] = $process->getPid();
|
||||
$this->onOutput($buffer, $data);
|
||||
@@ -235,7 +236,16 @@ class Youtube
|
||||
}
|
||||
public function isInstalled()
|
||||
{
|
||||
return (bool) (isset($this->bin) && @is_executable($this->bin));
|
||||
return @is_file($this->bin);
|
||||
}
|
||||
public function isExecutable()
|
||||
{
|
||||
return @is_executable($this->bin);
|
||||
}
|
||||
|
||||
public function getBin()
|
||||
{
|
||||
return $this->bin;
|
||||
}
|
||||
public static function install()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user