fixed #15;added support for downloading via bittorrent files;added new class for getting download statistics
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user