File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ $torrent = $qbt->torrent($hash);
6161This torrent object may then interact with the torrent API. To get a list of all torrents use the ` torrents ` method:
6262
6363``` php
64+ // Note: `torrents/info` is implemented in the base qbittorrent class instead of the Torrent class
6465$torrents = $qbt->torrents();
6566foreach ($torrents as $torrent_data) {
6667 $torrent = $qbt->torrent($torrent_data->hash);
Original file line number Diff line number Diff line change @@ -151,7 +151,25 @@ public function sync(): Sync {
151151 return $ this ->cloneApiObject ($ sync );
152152 }
153153
154- public function torrents (array $ options = []): array {
154+ public function torrents (
155+ ?string $ filter = null ,
156+ ?string $ category = null ,
157+ ?string $ tag = null ,
158+ ?string $ sort = null ,
159+ ?bool $ reverse = null ,
160+ ?int $ limit = null ,
161+ ?int $ offset = null ,
162+ ?string $ hashes = null
163+ ): array {
164+ $ options = [];
165+ $ ref = new \ReflectionMethod ($ this , 'torrents ' );
166+ foreach ($ ref ->getParameters () as $ param ) {
167+ $ value = $ {$ param ->name };
168+ if (!is_null ($ value )) {
169+ $ options [$ param ->name ] = $ value ;
170+ }
171+ }
172+
155173 $ response = $ this ->client ->get ('torrents/info ' , ['query ' => $ options ]);
156174 $ body = $ response ->getBody ();
157175 $ data = json_decode ($ body ->getContents ());
Original file line number Diff line number Diff line change @@ -37,6 +37,24 @@ public function peers(int $rid = 0): object {
3737 return $ this ->sync ()->torrentPeers ($ this ->getHash (), $ rid );
3838 }
3939
40+ public function properties (): object {
41+ $ response = $ this ->client ->get ($ this ->prefix . 'files ' , [
42+ 'query ' => [
43+ 'hash ' => $ this ->hash
44+ ]
45+ ]);
46+
47+ if ($ response ->getStatusCode () === 404 ) {
48+ return (object )[];
49+ }
50+
51+ $ body = $ response ->getBody ();
52+ $ data = json_decode ($ body ->getContents ());
53+ $ body ->close ();
54+
55+ return $ data ;
56+ }
57+
4058 public function renameFile (string $ old_path , string $ new_path ): ResponseInterface {
4159 return $ this ->client ->post ($ this ->prefix . 'renameFile ' , [
4260 'form_params ' => [
You can’t perform that action at this time.
0 commit comments