fixed #9; tweaked aria2 settings(including disabling certificate check);added aria2 event hooks;other minor changes;
This commit is contained in:
@@ -2,21 +2,18 @@
|
||||
|
||||
namespace OCA\NCDownloader\Command;
|
||||
|
||||
use OCA\NCDownloader\Search\torrentSearch;
|
||||
use OCA\NCDownloader\Tools\Aria2;
|
||||
use OCA\NCDownloader\Tools\DBConn;
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
use OC\Core\Command\Base;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Aria2Command extends base
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->conn = new DBConn();
|
||||
$this->aria2 = new Aria2();
|
||||
$this->dbconn = new DBConn();
|
||||
parent::__construct();
|
||||
}
|
||||
protected function configure()
|
||||
@@ -27,20 +24,17 @@ class Aria2Command extends base
|
||||
'action',
|
||||
InputArgument::OPTIONAL,
|
||||
'Aria2 hook names: start,complete,error'
|
||||
)->addOption(
|
||||
)->addArgument(
|
||||
'gid',
|
||||
'g',
|
||||
InputOption::VALUE_REQUIRED,
|
||||
InputArgument::OPTIONAL,
|
||||
'Aria2 gid'
|
||||
)->addOption(
|
||||
)->addArgument(
|
||||
'path',
|
||||
'p',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
InputArgument::OPTIONAL,
|
||||
'Downloaded file path'
|
||||
)->addOption(
|
||||
'number',
|
||||
'N',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
)->addArgument(
|
||||
'numFiles',
|
||||
InputArgument::OPTIONAL,
|
||||
'Number of Files',
|
||||
1
|
||||
);
|
||||
@@ -48,31 +42,23 @@ class Aria2Command extends base
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
||||
if (!$action = $input->getArgument('action')) {
|
||||
$action = 'start';
|
||||
}
|
||||
$search = new torrentSearch();
|
||||
$search->setSite('bitSearch');
|
||||
$data = $search->go('test');
|
||||
$gid = $input->getOption('gid');
|
||||
$path = $input->getOption('path');
|
||||
$numFile = $input->getOption('number');
|
||||
if (!$gid) {
|
||||
return 1;
|
||||
}
|
||||
$parent_gid = $this->aria2->getFollowingGid($gid); // $this->conn->getAll();
|
||||
if ($parent_gid) {
|
||||
$tablename = $this->conn->queryBuilder->getTableName("ncdownloader_info");
|
||||
$sql = sprintf("UPDATE %s set followedby = ? WHERE gid = ?", $tablename);
|
||||
// $data = serialize(['followedby' => "82140bd962946ae0"]);
|
||||
$this->conn->execute($sql, [$gid, $parent_gid]);
|
||||
|
||||
$gid = $input->getArgument('gid');
|
||||
if (!is_string($gid)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$result = $this->conn->getByGid($parent_gid);
|
||||
//$data = unserialize($result['data']);
|
||||
$output->writeln(print_r($result, true));
|
||||
return 0;
|
||||
if (in_array($action, ['complete', 'error'])) {
|
||||
$status = strtoupper($action);
|
||||
$this->dbconn->updateStatus($gid, Helper::STATUS[$status]);
|
||||
}
|
||||
if ($action === 'start') {
|
||||
//Helper::log("$gid started");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user