fixed #15;added support for downloading via bittorrent files;added new class for getting download statistics

This commit is contained in:
huangjx
2021-10-21 18:18:41 +08:00
parent c2ce945aad
commit 5037180a40
12 changed files with 190 additions and 36 deletions

View File

@@ -3,12 +3,15 @@
namespace OCA\NCDownloader\Search;
require __DIR__ . "/../../vendor/autoload.php";
use OCP\AppFramework\QueryException;
use OCP\IServerContainer;
use Symfony\Component\HttpClient\Exception\ClientException;
class torrentSearch
{
public $container;
private $site = null;
private $defaultSite = __NAMESPACE__ . '\Sites\TPB';
public function __construct()
{
$this->container = \OC::$server->query(IServerContainer::class);
@@ -16,7 +19,13 @@ class torrentSearch
}
public function go($keyword)
{
$siteInst = $this->container->query($this->site);
try {
$siteInst = $this->container->query($this->site);
} catch (QueryException $e) {
$siteInst = $this->container->query($this->defaultSite);
} catch (ClientException $e) {
return ['message', $e->getMessage()];
}
$data = $siteInst->search($keyword);
$this->addAction($data);
return $data;