From 32e14f9471ac0991f4d08031c4ef51110c9732c4 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Fri, 17 Jan 2020 11:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0IDE=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Client/AbstractClientInterface.php | 1 + app/Client/Transmission/TransmissionRPC.php | 73 +++++++++++++-------- composer.json | 23 +++---- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/app/Client/AbstractClientInterface.php b/app/Client/AbstractClientInterface.php index 5efb23a..80d9e18 100644 --- a/app/Client/AbstractClientInterface.php +++ b/app/Client/AbstractClientInterface.php @@ -10,4 +10,5 @@ namespace IYUU\Client; interface AbstractClientInterface { + } diff --git a/app/Client/Transmission/TransmissionRPC.php b/app/Client/Transmission/TransmissionRPC.php index e476418..54bdff3 100644 --- a/app/Client/Transmission/TransmissionRPC.php +++ b/app/Client/Transmission/TransmissionRPC.php @@ -131,10 +131,40 @@ class TransmissionRPC implements AbstractClientInterface const RPC_LT_14_TR_STATUS_SEED = 8; const RPC_LT_14_TR_STATUS_STOPPED = 16; + /** + * Takes the connection parameters + * + * TODO: Sanitize username, password, and URL + * + * @param string $url + * @param string $username + * @param string $password + */ + public function __construct($url = 'http://localhost:9091/transmission/rpc', $username = null, $password = null, $return_as_array = false) + { + // server URL + $this->url = $url; + + // Username & password + $this->username = $username; + $this->password = $password; + + // Get the Transmission RPC_version + $this->rpc_version = self::sget()->arguments->rpc_version; + + // Return As Array + $this->return_as_array = $return_as_array; + + // Reset X-Transmission-Session-Id so we (re)fetch one + $this->session_id = null; + } + /** * Start one or more torrents * * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function start($ids) { @@ -149,6 +179,8 @@ class TransmissionRPC implements AbstractClientInterface * Stop one or more torrents * * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function stop($ids) { @@ -163,6 +195,8 @@ class TransmissionRPC implements AbstractClientInterface * Reannounce one or more torrents * * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function reannounce($ids) { @@ -177,6 +211,8 @@ class TransmissionRPC implements AbstractClientInterface * Verify one or more torrents * * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function verify($ids) { @@ -225,6 +261,8 @@ class TransmissionRPC implements AbstractClientInterface * "result": "success", * "tag": 39693 * } + * @return mixed + * @throws TransmissionRPCException */ public function get($ids = array(), $fields = array()) { @@ -263,6 +301,8 @@ class TransmissionRPC implements AbstractClientInterface * * @param array arguments An associative array of arguments to set * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function set($ids = array(), $arguments = array()) { @@ -345,6 +385,8 @@ class TransmissionRPC implements AbstractClientInterface * * @param bool delete_local_data Also remove local data? * @param int|array ids A list of transmission torrent ids + * @return mixed + * @throws TransmissionRPCException */ public function remove($ids, $delete_local_data = false) { @@ -364,6 +406,8 @@ class TransmissionRPC implements AbstractClientInterface * @param int|array ids A list of transmission torrent ids * @param string target_location The new storage location * @param string move_existing_data Move existing data or scan new location for available data + * @return mixed + * @throws TransmissionRPCException */ public function move($ids, $target_location, $move_existing_data = true) { @@ -653,6 +697,7 @@ class TransmissionRPC implements AbstractClientInterface * and store it in $this->session_id * * @return string + * @throws TransmissionRPCException */ public function GetSessionID() { @@ -713,32 +758,4 @@ class TransmissionRPC implements AbstractClientInterface } return $this->session_id; } - - /** - * Takes the connection parameters - * - * TODO: Sanitize username, password, and URL - * - * @param string $url - * @param string $username - * @param string $password - */ - public function __construct($url = 'http://localhost:9091/transmission/rpc', $username = null, $password = null, $return_as_array = false) - { - // server URL - $this->url = $url; - - // Username & password - $this->username = $username; - $this->password = $password; - - // Get the Transmission RPC_version - $this->rpc_version = self::sget()->arguments->rpc_version; - - // Return As Array - $this->return_as_array = $return_as_array; - - // Reset X-Transmission-Session-Id so we (re)fetch one - $this->session_id = null; - } } diff --git a/composer.json b/composer.json index 04d3777..70a20c0 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,15 @@ { - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "owner888/phpspider": "^2.1", - "curl/curl": "^2.2" + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-curl": "*", + "owner888/phpspider": "^2.1", + "curl/curl": "^2.2" + }, + "autoload": { + "psr-4": { + "IYUU\\": "app/" }, - "autoload": { - "psr-4": { - "IYUU\\": "app/" - }, - "files": ["app/helper.php"] - } + "files": ["app/helper.php"] + } }