Compare commits
2 commits
master
...
dev-master
Author | SHA1 | Date | |
---|---|---|---|
Simon Vieille | 2dbbed4d30 | ||
Simon Vieille | e116e37648 |
|
@ -8,9 +8,9 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Api\ConfigLoader;
|
use Api\ConfigLoader;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
use Vohof\Transmission;
|
|
||||||
use Transmission\Client\GuzzleClient;
|
use Transmission\Client\GuzzleClient;
|
||||||
use Helper\Formater;
|
use Helper\Formater;
|
||||||
|
use Transmission\Transmission;
|
||||||
|
|
||||||
class TransmissionStatsCommand extends Command
|
class TransmissionStatsCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
68
src/Transmission/Transmission.php
Normal file
68
src/Transmission/Transmission.php
Normal 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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue