mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-06-13 04:08:57 +00:00
使用ClientInterface优化
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
namespace IYUU;
|
namespace IYUU;
|
||||||
|
|
||||||
use Curl\Curl;
|
use Curl\Curl;
|
||||||
|
use IYUU\Client\AbstractClientInterface;
|
||||||
use IYUU\Client\qBittorrent\qBittorrent;
|
use IYUU\Client\qBittorrent\qBittorrent;
|
||||||
use IYUU\Client\Transmission\TransmissionRPC;
|
use IYUU\Client\Transmission\TransmissionRPC;
|
||||||
use IYUU\Library\IFile;
|
use IYUU\Library\IFile;
|
||||||
@ -116,21 +117,22 @@ class AutoReseed
|
|||||||
try {
|
try {
|
||||||
switch ($v['type']) {
|
switch ($v['type']) {
|
||||||
case 'transmission':
|
case 'transmission':
|
||||||
self::$links[$k]['rpc'] = new TransmissionRPC($v['host'], $v['username'], $v['password']);
|
$client = new TransmissionRPC($v['host'], $v['username'], $v['password']);
|
||||||
$result = self::$links[$k]['rpc']->sstats();
|
|
||||||
print $v['type'].':'.$v['host']." Rpc连接 [{$result->result}] \n";
|
|
||||||
break;
|
break;
|
||||||
case 'qBittorrent':
|
case 'qBittorrent':
|
||||||
self::$links[$k]['rpc'] = new qBittorrent($v['host'], $v['username'], $v['password']);
|
$client = new qBittorrent($v['host'], $v['username'], $v['password']);
|
||||||
$result = self::$links[$k]['rpc']->appVersion();
|
|
||||||
print $v['type'].':'.$v['host']." Rpc连接 [{$result}] \n";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo '[ERROR] '.$v['type'];
|
echo '[ERROR] '.$v['type'];
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/** @var AbstractClientInterface $client */
|
||||||
self::$links[$k]['type'] = $v['type'];
|
self::$links[$k]['type'] = $v['type'];
|
||||||
|
self::$links[$k]['rpc'] = $client;
|
||||||
|
$result = $client->status();
|
||||||
|
|
||||||
|
print $v['type'].':'.$v['host']." Rpc连接 [{$result->result}] \n";
|
||||||
// 检查是否转移种子的做种客户端?
|
// 检查是否转移种子的做种客户端?
|
||||||
if (isset($v['move']) && $v['move']) {
|
if (isset($v['move']) && $v['move']) {
|
||||||
self::$move = array($k,$v['type']);
|
self::$move = array($k,$v['type']);
|
||||||
|
@ -11,4 +11,11 @@ namespace IYUU\Client;
|
|||||||
interface AbstractClientInterface
|
interface AbstractClientInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询Bittorrent客户端状态
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function status();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -758,4 +758,12 @@ class TransmissionRPC implements AbstractClientInterface
|
|||||||
}
|
}
|
||||||
return $this->session_id;
|
return $this->session_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function status()
|
||||||
|
{
|
||||||
|
return $this->sstats();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,4 +295,12 @@ class qBittorrent implements AbstractClientInterface
|
|||||||
$data .= "--" . $this->delimiter . "--" . $eol;
|
$data .= "--" . $this->delimiter . "--" . $eol;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function status()
|
||||||
|
{
|
||||||
|
return $this->appVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* 调试函数
|
* 调试函数
|
||||||
|
* @param $data
|
||||||
|
* @param bool $echo
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
function p($data, $echo=true)
|
function p($data, $echo=true)
|
||||||
{
|
{
|
||||||
@ -24,6 +27,9 @@ function p($data, $echo=true)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信推送Server酱
|
* 微信推送Server酱
|
||||||
|
* @param string $text
|
||||||
|
* @param string $desp
|
||||||
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
function sc($text='', $desp='')
|
function sc($text='', $desp='')
|
||||||
{
|
{
|
||||||
@ -46,6 +52,9 @@ function sc($text='', $desp='')
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信推送 爱语飞飞
|
* 微信推送 爱语飞飞
|
||||||
|
* @param string $text
|
||||||
|
* @param string $desp
|
||||||
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
function ff($text='', $desp='')
|
function ff($text='', $desp='')
|
||||||
{
|
{
|
||||||
@ -68,30 +77,32 @@ function ff($text='', $desp='')
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信推送 爱语飞飞
|
* 微信推送 爱语飞飞
|
||||||
* @param array $torrent 种子数组
|
* @param string $site
|
||||||
Array
|
* @param array $torrent 种子数组
|
||||||
(
|
* Array
|
||||||
[id] => 118632
|
* (
|
||||||
[h1] => CCTV5+ 2019 ATP Men's Tennis Final 20191115B HDTV 1080i H264-HDSTV
|
* [id] => 118632
|
||||||
[title] => 央视体育赛事频道 2019年ATP男子网球年终总决赛 单打小组赛 纳达尔VS西西帕斯 20191115[优惠剩余时间:4时13分]
|
* [h1] => CCTV5+ 2019 ATP Men's Tennis Final 20191115B HDTV 1080i H264-HDSTV
|
||||||
[details] => https://xxx.me/details.php?id=118632
|
* [title] => 央视体育赛事频道 2019年ATP男子网球年终总决赛 单打小组赛 纳达尔VS西西帕斯 20191115[优惠剩余时间:4时13分]
|
||||||
[download] => https://xxx.me/download.php?id=118632
|
* [details] => https://xxx.me/details.php?id=118632
|
||||||
[filename] => 118632.torrent
|
* [download] => https://xxx.me/download.php?id=118632
|
||||||
[type] => 0
|
* [filename] => 118632.torrent
|
||||||
[sticky] => 1
|
* [type] => 0
|
||||||
[time] => Array
|
* [sticky] => 1
|
||||||
(
|
* [time] => Array
|
||||||
[0] => "2019-11-16 20:41:53">4时13分
|
* (
|
||||||
[1] => "2019-11-16 14:41:53">1时<br />46分
|
* [0] => "2019-11-16 20:41:53">4时13分
|
||||||
)
|
* [1] => "2019-11-16 14:41:53">1时<br />46分
|
||||||
[comments] => 0
|
* )
|
||||||
[size] => 5232.64MB
|
* [comments] => 0
|
||||||
[seeders] => 69
|
* [size] => 5232.64MB
|
||||||
[leechers] => 10
|
* [seeders] => 69
|
||||||
[completed] => 93
|
* [leechers] => 10
|
||||||
[percentage] => 100%
|
* [completed] => 93
|
||||||
[owner] => 匿名
|
* [percentage] => 100%
|
||||||
)
|
* [owner] => 匿名
|
||||||
|
* )
|
||||||
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
function send($site = '', $torrent = array())
|
function send($site = '', $torrent = array())
|
||||||
{
|
{
|
||||||
@ -120,7 +131,9 @@ function send($site = '', $torrent = array())
|
|||||||
/**
|
/**
|
||||||
* @brief 下载种子
|
* @brief 下载种子
|
||||||
* @param string $url 种子URL
|
* @param string $url 种子URL
|
||||||
* @param string $cookies 模拟登陆的cookie
|
* @param string $cookies 模拟登陆的cookie
|
||||||
|
* @param $useragent
|
||||||
|
* @param string $method
|
||||||
* @return mixed 返回的数据
|
* @return mixed 返回的数据
|
||||||
*/
|
*/
|
||||||
function download($url, $cookies, $useragent, $method = 'GET')
|
function download($url, $cookies, $useragent, $method = 'GET')
|
||||||
|
Reference in New Issue
Block a user