完善各种日志的输出

master
iyuu.cn 5 years ago
parent 51f3fa39bc
commit ef2668ca54
  1. 88
      app/AutoReseed.php
  2. 2
      app/Client/qBittorrent/qBittorrent.php

@ -355,25 +355,15 @@ class AutoReseed
$hashArray['sign'] = Oauth::getSign(); $hashArray['sign'] = Oauth::getSign();
$hashArray['version'] = self::VER; $hashArray['version'] = self::VER;
// 写请求日志 // 写请求日志
if (true) { wlog($hashArray,'hashString');
// 文件句柄
$resource = fopen(self::$cacheDir.'hashString.txt', "wb");
// 成功:返回写入字节数,失败返回false
$worldsnum = fwrite($resource, p($hashArray, false));
fclose($resource);
}
// 发起请求 // 发起请求
echo "正在提交辅种信息…… \n"; echo "正在提交辅种信息…… \n";
$res = $curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray); $res = $curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray);
$resArray = json_decode($res->response, true); $resArray = json_decode($res->response, true);
// 写返回日志 // 写返回日志
if (true) { wlog($resArray,'reseed');
// 文件句柄
$resource = fopen(self::$cacheDir.'reseed.txt', "wb");
// 成功:返回写入字节数,失败返回false
$worldsnum = fwrite($resource, p($resArray, false));
fclose($resource);
}
// 判断返回值 // 判断返回值
if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) { if (isset($resArray['errmsg']) && ($resArray['errmsg'] == 'ok')) {
echo "辅种信息提交成功!!! \n\n"; echo "辅种信息提交成功!!! \n\n";
@ -430,6 +420,12 @@ class AutoReseed
// 流控检测 // 流控检测
if (isset($configALL[$sites[$sitesID]['site']]['limit'])) { if (isset($configALL[$sites[$sitesID]['site']]['limit'])) {
echo "-------因当前" .$sites[$sitesID]['site']. "站点触发流控,已跳过!! {$_url} \n\n"; echo "-------因当前" .$sites[$sitesID]['site']. "站点触发流控,已跳过!! {$_url} \n\n";
// 流控日志
if ($sites[$sitesID]['site'] == 'hdchina') {
$details_page = str_replace('{}', $value['torrent_id'], 'details.php?id={}&hit=1');
$_url = 'https://' .$sites[$sitesID]['base_url']. '/' .$details_page;
}
wlog('clients_'.$k."\n".$downloadDir."\n"."-------因当前" .$sites[$sitesID]['site']. "站点触发流控,已跳过!! {$_url} \n\n",'reseedLimit');
self::$wechatMsg['reseedSkip']++; self::$wechatMsg['reseedSkip']++;
continue; continue;
} }
@ -527,35 +523,28 @@ class AutoReseed
$ret = false; $ret = false;
// 成功返回:true // 成功返回:true
$ret = self::add($k, $url, $downloadDir); $ret = self::add($k, $url, $downloadDir);
// 按站点规范日志内容
switch ($sites[$sitesID]['site']) {
case 'hdchina':
$url = $details_url;
break;
case 'hdcity':
$url = $_url;
break;
default:
break;
}
// 添加成功的种子,以infohash为文件名,写入缓存 // 添加成功的种子,以infohash为文件名,写入缓存
if ($ret) { if ($ret) {
// 成功的种子 // 成功的种子
switch ($sites[$sitesID]['site']) { wlog($url."\n", $value['info_hash'], self::$cacheHash);
case 'hdchina': wlog($url."\n",'reseedSuccess');
$url = $details_url; // 成功累加
break;
case 'hdcity':
$url = $_url;
break;
default:
break;
}
// 文件句柄
$resource = fopen(self::$cacheHash . $value['info_hash'].'.txt', "wb");
// 成功:返回写入字节数,失败返回false
$worldsnum = fwrite($resource, $url);
fclose($resource);
self::$wechatMsg['reseedSuccess']++; self::$wechatMsg['reseedSuccess']++;
continue; continue;
} else { } else {
// 失败的种子 // 失败的种子
// 不同站点的错误提示 wlog($url."\n",'reseedError');
switch ($sites[$sitesID]['site']) {
case 'hdcity':
break;
default:
break;
}
// 失败累加 // 失败累加
self::$wechatMsg['reseedError']++; self::$wechatMsg['reseedError']++;
continue; continue;
@ -565,22 +554,19 @@ class AutoReseed
* 不辅种 * 不辅种
*/ */
echo '-------已跳过不辅种的站点:'.$_url."\n\n"; echo '-------已跳过不辅种的站点:'.$_url."\n\n";
// 写入日志文件,供用户手动辅种 // 按站点规范日志内容
if (!isset($infohash_Dir[$value['info_hash']])) { switch ($sites[$sitesID]['site']) {
// 站点类型判断 case 'hdchina':
switch ($sites[$sitesID]['site']) { $url = $details_url;
case 'hdchina': break;
$url = $_url; case 'hdcity':
break; $url = $_url;
default: break;
break; default:
} break;
// 文件句柄
$resource = fopen(self::$cacheDir . $sites[$sitesID]['site'].'.txt', 'a');
// 成功:返回写入字节数,失败返回false
$worldsnum = fwrite($resource, 'clients_'.$k."\n".$downloadDir."\n".$url."\n".$details_url."\n\n");
fclose($resource);
} }
// 写入日志文件,供用户手动辅种
wlog('clients_'.$k."\n".$downloadDir."\n".$url."\n".$details_url."\n\n", $sites[$sitesID]['site']);
} }
} }
} }

@ -87,7 +87,7 @@ class qBittorrent implements AbstractClientInterface
$this->curl->setOpt(CURLOPT_TIMEOUT, 600); // 超时 $this->curl->setOpt(CURLOPT_TIMEOUT, 600); // 超时
// Authenticate and get cookie, else throw exception // Authenticate and get cookie, else throw exception
if (!$this->authenticate()) { if (!$this->authenticate()) {
throw new \Exception("Unable to authenticate with Web Api."); throw new \Exception("qBittorrent Unable to authenticate with Web Api.");
} }
} }

Loading…
Cancel
Save