forked from deblan/t411-console
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Transmission;
|
|
|
|
use Vohof\Transmission as BaseTransmission;
|
|
use Vohof\ClientAbstract;
|
|
|
|
/**
|
|
* Class doo
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
*/
|
|
class Transmission extends BaseTransmission
|
|
{
|
|
public function __construct(array $config, ClientAbstract $client = null)
|
|
{
|
|
parent::__construct($config, $client);
|
|
|
|
$this->config = $config;
|
|
|
|
foreach(array('host', 'endpoint') as $requirement)
|
|
{
|
|
if ( ! isset($config[$requirement]))
|
|
{
|
|
throw new \InvalidArgumentException("Missing argument: $requirement");
|
|
}
|
|
}
|
|
|
|
if (is_null($client))
|
|
{
|
|
$options = array();
|
|
|
|
if (isset($config['username']) and isset($config['password']))
|
|
{
|
|
$options = array(
|
|
'request.options' => array(
|
|
'auth' => array($config['username'], $config['password'])
|
|
)
|
|
);
|
|
}
|
|
|
|
$this->client = new GuzzleClient($config['host'], $options);
|
|
}
|
|
else
|
|
{
|
|
$this->client = $client;
|
|
}
|
|
|
|
$this->client->setEndpoint($config['endpoint']);
|
|
}
|
|
|
|
// public function add($url, $isEncoded = false, $options = array())
|
|
// {
|
|
// $options[$isEncoded ? 'metainfo' : 'filename'] = $url;
|
|
|
|
// return $this->client->request('torrent-add', $options);
|
|
// }
|
|
|
|
// public function foo()
|
|
// {
|
|
// $options = [
|
|
// 'fields' => static::$fields,
|
|
// 'ids' => ['all'],
|
|
// ];
|
|
//
|
|
// return $this->client->request('torrent-get', $options);
|
|
// }
|
|
}
|
|
|