Compare commits

..

5 Commits

Author SHA1 Message Date
iyuu.cn
61eb8f69c9 简化辅种输出。 2020-03-22 11:29:47 +08:00
iyuu.cn
b4ca455a75 优化输出提示,未填写passkey的站点自动跳过,不提示。 2020-03-22 11:24:52 +08:00
iyuu.cn
02205e6ce3 修复transmission往qBittorrent转移种子,错误的问题。 2020-03-21 19:33:50 +08:00
iyuu.cn
818794a19b 错误提示后面增加换行符。 2020-03-19 19:58:10 +08:00
iyuu.cn
88bc79ff58 版本升级至v1.6.7 2020-03-16 15:00:00 +08:00

View File

@@ -13,19 +13,19 @@ use IYUU\Library\Table;
class AutoReseed class AutoReseed
{ {
// 版本号 // 版本号
const VER = '1.6.3'; const VER = '1.6.9';
// RPC连接 // RPC连接
private static $links = array(); private static $links = [];
// 客户端配置 // 客户端配置
private static $clients = array(); private static $clients = [];
// 站点列表 // 站点列表
private static $sites = array(); private static $sites = [];
// 不辅种的站点 'ourbits','hdchina' // 不辅种的站点 'pt','hdchina'
private static $noReseed = array(); private static $noReseed = [];
// 不转移的站点 'hdarea','hdbd' // 不转移的站点 'hdarea','hdbd'
private static $noMove = array(''); private static $noMove = [];
// cookie检查 // cookie检查
private static $cookieCheck = array('hdchina','hdcity'); private static $cookieCheck = ['hdchina','hdcity'];
// 缓存路径 // 缓存路径
public static $cacheDir = TORRENT_PATH.'cache'.DS; public static $cacheDir = TORRENT_PATH.'cache'.DS;
public static $cacheHash = TORRENT_PATH.'cachehash'.DS; public static $cacheHash = TORRENT_PATH.'cachehash'.DS;
@@ -69,6 +69,7 @@ class AutoReseed
public static function init() public static function init()
{ {
global $configALL; global $configALL;
echo "版本号:".self::VER.PHP_EOL;
self::backup('config', $configALL); self::backup('config', $configALL);
self::$curl = new Curl(); self::$curl = new Curl();
self::$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); self::$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
@@ -77,7 +78,7 @@ class AutoReseed
// 合作站点自动注册鉴权 // 合作站点自动注册鉴权
$is_login = Oauth::login(self::$apiUrl . self::$endpoints['login']); $is_login = Oauth::login(self::$apiUrl . self::$endpoints['login']);
if(!$is_login){ if(!$is_login){
echo '合作站点鉴权配置请查阅https://www.iyuu.cn/archives/337/'; echo '合作站点鉴权配置请查阅https://www.iyuu.cn/archives/337/' .PHP_EOL;
} }
// 显示支持站点列表 // 显示支持站点列表
@@ -99,9 +100,10 @@ class AutoReseed
*/ */
private static function ShowTableSites() private static function ShowTableSites()
{ {
$list[] = 'gitee 源码仓库https://gitee.com/ledc/IYUUAutoReseed'; $list[] = 'gitee源码仓库https://gitee.com/ledc/IYUUAutoReseed';
$list[] = 'github源码仓库https://github.com/ledccn/IYUUAutoReseed'; $list[] = 'github源码仓库https://github.com/ledccn/IYUUAutoReseed';
$list[] = '教程https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki'; $list[] = '教程https://gitee.com/ledc/IYUUAutoReseed/tree/master/wiki';
$list[] = '问答社区http://wenda.iyuu.cn';
$list[] = "QQ群859882209 【IYUU自动辅种交流】".PHP_EOL; $list[] = "QQ群859882209 【IYUU自动辅种交流】".PHP_EOL;
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
echo $value.PHP_EOL; echo $value.PHP_EOL;
@@ -122,10 +124,10 @@ class AutoReseed
@fclose($file_pointer); @fclose($file_pointer);
} else { } else {
if (isset($rs['msg']) && $rs['msg']) { if (isset($rs['msg']) && $rs['msg']) {
die($rs['msg']); die($rs['msg'].PHP_EOL);
} }
if (isset($rs['errmsg']) && $rs['errmsg']) { if (isset($rs['errmsg']) && $rs['errmsg']) {
die($rs['errmsg']); die($rs['errmsg'].PHP_EOL);
} }
die('远端服务器无响应,请稍后再试!!!'); die('远端服务器无响应,请稍后再试!!!');
} }
@@ -167,7 +169,7 @@ class AutoReseed
self::$links[$k]['BT_backup'] = isset($v['BT_backup']) && $v['BT_backup'] ? $v['BT_backup'] : ''; self::$links[$k]['BT_backup'] = isset($v['BT_backup']) && $v['BT_backup'] ? $v['BT_backup'] : '';
$result = $client->status(); $result = $client->status();
print $v['type'].''.$v['host']." Rpc连接 [{$result}] \n"; print $v['type'].''.$v['host']." Rpc连接 [{$result}] \n";
// 检查转移做种 // 检查转移做种 (移动配置为真、self::$move为空)
if (isset($v['move']) && $v['move'] && is_null(self::$move)) { if (isset($v['move']) && $v['move'] && is_null(self::$move)) {
self::$move = array($k,$v['move']); self::$move = array($k,$v['move']);
} }
@@ -319,6 +321,7 @@ class AutoReseed
// 判断返回值 // 判断返回值
if (empty($res['msg'])) { if (empty($res['msg'])) {
echo "clients_".$k." 辅种数据下载成功!!!".PHP_EOL.PHP_EOL; echo "clients_".$k." 辅种数据下载成功!!!".PHP_EOL.PHP_EOL;
echo '【提醒】未配置passkey的站点都会跳过'.PHP_EOL.PHP_EOL;
} else { } else {
$errmsg = isset($res['msg']) && $res['msg'] ? $res['msg'] : '远端服务器无响应,请稍后重试!'; $errmsg = isset($res['msg']) && $res['msg'] ? $res['msg'] : '远端服务器无响应,请稍后重试!';
echo '-----辅种失败,原因:' .$errmsg.PHP_EOL.PHP_EOL; echo '-----辅种失败,原因:' .$errmsg.PHP_EOL.PHP_EOL;
@@ -349,15 +352,17 @@ class AutoReseed
// 页面规则 // 页面规则
$download_page = str_replace('{}', $torrent_id, $sites[$sid]['download_page']); $download_page = str_replace('{}', $torrent_id, $sites[$sid]['download_page']);
$_url = 'https://' .$sites[$sid]['base_url']. '/' .$download_page; $_url = 'https://' .$sites[$sid]['base_url']. '/' .$download_page;
echo "clients_".$k."正在辅种... {$siteName}".PHP_EOL;
/** /**
* 前置检测 * 前置检测
*/ */
// passkey检测 // passkey检测
if (empty($configALL[$siteName]['passkey'])) { if (empty($configALL[$siteName]['passkey'])) {
echo '-------因当前' .$siteName. "站点未设置passkey已跳过".PHP_EOL.PHP_EOL; //echo '-------因当前' .$siteName. "站点未设置passkey已跳过".PHP_EOL.PHP_EOL;
self::$wechatMsg['reseedSkip']++; self::$wechatMsg['reseedSkip']++;
continue; continue;
}else{
echo "clients_".$k."正在辅种... {$siteName}".PHP_EOL;
} }
// cookie检测 // cookie检测
if (in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie'])) { if (in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie'])) {
@@ -553,7 +558,8 @@ class AutoReseed
continue; continue;
} }
echo "正在从下载器 clients_".$k." 获取种子哈希……".PHP_EOL; echo "正在从下载器 clients_".$k." 获取种子哈希……".PHP_EOL;
$hashArray = self::$links[$k]['rpc']->getList(self::$move); $move = []; // 客户端做种列表 传址
$hashArray = self::$links[$k]['rpc']->getList($move);
if (empty($hashArray)) { if (empty($hashArray)) {
// 失败 // 失败
continue; continue;
@@ -614,7 +620,7 @@ class AutoReseed
$torrent = file_get_contents($torrentPath); $torrent = file_get_contents($torrentPath);
// 正式开始转移 // 正式开始转移
echo "种子已推送给下载器,正在转移做种...".PHP_EOL; echo "种子已推送给下载器,正在转移做种...".PHP_EOL;
$ret = false;
// 目标下载器类型 // 目标下载器类型
$rpcKey = self::$move[0]; $rpcKey = self::$move[0];
$type = self::$links[$rpcKey]['type']; $type = self::$links[$rpcKey]['type'];
@@ -626,6 +632,7 @@ class AutoReseed
} }
} else { } else {
} }
// 添加转移任务成功返回true // 添加转移任务成功返回true
$ret = self::add(self::$move[0], $torrent, $downloadDir, $extra_options); $ret = self::add(self::$move[0], $torrent, $downloadDir, $extra_options);
/** /**
@@ -788,5 +795,6 @@ class AutoReseed
$file_pointer = @fopen($myfile, "w"); $file_pointer = @fopen($myfile, "w");
$worldsnum = @fwrite($file_pointer, $json); $worldsnum = @fwrite($file_pointer, $json);
@fclose($file_pointer); @fclose($file_pointer);
return $worldsnum;
} }
} }