willicab / transmission
Transmission RPC 的 PHP 实现。
1.1.1
2018-10-29 05:24 UTC
Requires
- php: >=7.2
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-29 04:43:27 UTC
README
Transmission RPC 规范的另一个 PHP 实现。Transmission RPC 规范。
安装
您可以将它作为 Composer 包进行安装
composer require willicab/transmission
用法
默认情况下,使用 'https://' 作为主机,9091 作为端口,不使用用户名和密码
<?php require 'vendor/autoload.php'; use Willicab\Transmission\Client; $tm = new Client(); $tm->connect();
如果您可以设置参数,您可以将它们作为数组传递
<?php require 'vendor/autoload.php'; use Willicab\Transmission\Client; $arguments = [ 'host' => 'http://another.host', 'port' => 1234, 'user' => 'transmission', 'password' => 'transmission' ]; $tm = new Client($arguments); $tm->connect();
种子操作请求
参数是种子的 ID,可以是:
- 一个整数,指代种子 ID。
- 一组种子 ID 数字、sha1 哈希字符串或两者都包括的列表
- 一个字符串 "recently-active",表示最近活跃的种子
$tm->torrentStart(); $tm->torrentStartNow(1); $tm->torrentStop([1, 3, '3343d0e7c66f29d2f0ce9af951d367020eedc38c']); $tm->torrentVerify('recently-active'); $tm->torrentReannounce('3343d0e7c66f29d2f0ce9af951d367020eedc38c');
种子集
您可以在 规范文件 中查看可用参数,第 3.2 点。
$arguments = [ 'downloadLimit' => 1000, 'downloadLimited' => true, ]; $tm->torrentSet(2, $arguments); $tm->torrentSet(1, $arguments); $tm->torrentSet([1, 3, '3343d0e7c66f29d2f0ce9af951d367020eedc38c'], $arguments); $tm->torrentSet('recently-active', $arguments);
种子获取
您可以在 规范文件 中查看可用参数,第 3.3 点。
$arguments = ['id, 'name', 'downloadLimit', 'downloadLimited']; $tm->torrentGet(2, $arguments); $tm->torrentGet(1, $arguments); $tm->torrentGet([1, 3, '3343d0e7c66f29d2f0ce9af951d367020eedc38c'], $arguments); $tm->torrentGet('recently-active', $arguments);
添加种子
您可以在 规范文件 中查看可用参数,第 3.4 点。
您可以通过两种方法添加种子:
$arguments = [ 'download-dir' => '/home/user/Downloads/', 'paused' => true, ]; $tm->addFilename('magnet:?xt=urn:btih:c39fe3eefbdb62da9c27eb6398ff4a7d2e26e7ab&dn=Big.Buck.Bunny.BDRip.XviD-MEDiC&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969', $arguments); $tm->addFilename('https://cdimage.debian.org/debian-cd/current/amd64/bt-dvd/debian-9.5.0-amd64-DVD-1.iso.torrent', $arguments);
$arguments = [ 'download-dir' => '/home/user/Downloads/', 'paused' => true, ]; $tm->addMetainfo('ZDg6YW5ub3VuY2U0MTpodHRwOi8vYnR0cmFja2VyLmRlYmlhbi5vcmc6Njk ... wnJ273LLn4nZC2PNVQvHbmy89ucgL8I2QDGQZWU=', $arguments);
移除种子
$tm->torrentRemove(2); // remove from list $tm->torrentRemove('3343d0e7c66f29d2f0ce9af951d367020eedc38c', true); // remove from list and delete the files
移动种子
$tm->torrentSetLocation(1, '/home/user/Downloaded/', true);
重命名种子路径
$tm->torrentRenamePath(1, '/home/user/Downloads/The Torrent', '/home/user/Downloaded/My Torrent');
会话设置
您可以在 规范文件 中查看可用参数,第 4.1 点。
$arguments = [ 'download-dir' => '/home/user/Downloads/', 'start-added-torrents' => true, ]; $tm->sessionSet($arguments);
会话获取
$tm->sessionGet();
会话统计信息
$tm->sessionStats();
阻止列表
$tm->blocklistUpdate();
端口检查
$tm->portTest();
会话关闭
$tm->sessionClose();
队列移动请求
$tm->queueMove(1, 'top'); $tm->queueMove([2, 3], 'up'); $tm->queueMove('3343d0e7c66f29d2f0ce9af951d367020eedc38c', 'down'); $tm->queueMove(2, 'bottom');
可用空间
$tm->freeSpace('/home/user/Downloads/');