Compare commits

...

2 commits

Author SHA1 Message Date
Simon Vieille 2dbbed4d30 Merge branch 'master' into dev-master 2016-08-29 01:29:37 +02:00
Simon Vieille e116e37648 Transmission client 2016-05-13 00:31:57 +02:00
2 changed files with 69 additions and 1 deletions

View file

@ -8,9 +8,9 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Command\Command;
use Api\ConfigLoader;
use Symfony\Component\Console\Input\ArrayInput;
use Vohof\Transmission;
use Transmission\Client\GuzzleClient;
use Helper\Formater;
use Transmission\Transmission;
class TransmissionStatsCommand extends Command
{

View file

@ -0,0 +1,68 @@
<?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);
// }
}