mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-05-23 10:05:23 +00:00
规范代码
This commit is contained in:
parent
76c0cefca2
commit
ea158ddd55
@ -358,7 +358,7 @@ class AutoReseed
|
|||||||
if ($is_url) {
|
if ($is_url) {
|
||||||
print "种子:".$torrent . PHP_EOL;
|
print "种子:".$torrent . PHP_EOL;
|
||||||
}
|
}
|
||||||
print "-----RPC添加种子任务,失败 [{$errmsg}]" . PHP_EOL.PHP_EOL;
|
print "-----RPC添加种子任务,失败 [{$errmsg}]" . PHP_EOL.PHP_EOL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'qBittorrent':
|
case 'qBittorrent':
|
||||||
@ -404,9 +404,9 @@ class AutoReseed
|
|||||||
$hashArray['version'] = self::VER;
|
$hashArray['version'] = self::VER;
|
||||||
// 写请求日志
|
// 写请求日志
|
||||||
wlog($hashArray, 'hashString');
|
wlog($hashArray, 'hashString');
|
||||||
if ( self::$move!==null ) {
|
if (self::$move!==null) {
|
||||||
self::move($hashArray);
|
self::move($hashArray);
|
||||||
}
|
}
|
||||||
self::reseed($hashArray);
|
self::reseed($hashArray);
|
||||||
self::wechatMessage();
|
self::wechatMessage();
|
||||||
}
|
}
|
||||||
@ -414,13 +414,14 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* IYUUAutoReseed辅种
|
* IYUUAutoReseed辅种
|
||||||
*/
|
*/
|
||||||
public static function reseed($hashArray = array()){
|
public static function reseed($hashArray = array())
|
||||||
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
$sites = array();
|
$sites = array();
|
||||||
// 前置过滤
|
// 前置过滤
|
||||||
if ( self::$move!==null && self::$move[1]==2 ) {
|
if (self::$move!==null && self::$move[1]==2) {
|
||||||
foreach ($hashArray['hash'] as $key => $json) {
|
foreach ($hashArray['hash'] as $key => $json) {
|
||||||
if ( $key != 'clients_'.self::$move[0] ) {
|
if ($key != 'clients_'.self::$move[0]) {
|
||||||
$hashArray['hash'][$key] = '[]';
|
$hashArray['hash'][$key] = '[]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,13 +483,13 @@ class AutoReseed
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// cookie检测
|
// cookie检测
|
||||||
if ( in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie']) ) {
|
if (in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie'])) {
|
||||||
echo '-------因当前' .$siteName. '站点未设置cookie,已跳过!!' .PHP_EOL.PHP_EOL;
|
echo '-------因当前' .$siteName. '站点未设置cookie,已跳过!!' .PHP_EOL.PHP_EOL;
|
||||||
self::$wechatMsg['reseedSkip']++;
|
self::$wechatMsg['reseedSkip']++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 流控检测
|
// 流控检测
|
||||||
if ( isset($configALL[$siteName]['limit']) ) {
|
if (isset($configALL[$siteName]['limit'])) {
|
||||||
echo "-------因当前" .$siteName. "站点触发流控,已跳过!! {$_url}".PHP_EOL.PHP_EOL;
|
echo "-------因当前" .$siteName. "站点触发流控,已跳过!! {$_url}".PHP_EOL.PHP_EOL;
|
||||||
// 流控日志
|
// 流控日志
|
||||||
if ($siteName == 'hdchina') {
|
if ($siteName == 'hdchina') {
|
||||||
@ -500,13 +501,13 @@ class AutoReseed
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 重复做种检测
|
// 重复做种检测
|
||||||
if ( isset($value['info_hash']) && isset($infohash_Dir[$value['info_hash']]) ) {
|
if (isset($value['info_hash']) && isset($infohash_Dir[$value['info_hash']])) {
|
||||||
echo '-------与客户端现有种子重复:'.$_url.PHP_EOL.PHP_EOL;
|
echo '-------与客户端现有种子重复:'.$_url.PHP_EOL.PHP_EOL;
|
||||||
self::$wechatMsg['reseedRepeat']++;
|
self::$wechatMsg['reseedRepeat']++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 历史添加检测
|
// 历史添加检测
|
||||||
if ( is_file(self::$cacheHash . $value['info_hash'].'.txt') ) {
|
if (is_file(self::$cacheHash . $value['info_hash'].'.txt')) {
|
||||||
echo '-------当前种子上次辅种已成功添加,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
echo '-------当前种子上次辅种已成功添加,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
||||||
self::$wechatMsg['reseedPass']++;
|
self::$wechatMsg['reseedPass']++;
|
||||||
continue;
|
continue;
|
||||||
@ -518,7 +519,7 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* 检查站点是否可以辅种
|
* 检查站点是否可以辅种
|
||||||
*/
|
*/
|
||||||
if ( (in_array($siteName, self::$noReseed)==false) ) {
|
if ((in_array($siteName, self::$noReseed)==false)) {
|
||||||
/**
|
/**
|
||||||
* 可以辅种
|
* 可以辅种
|
||||||
*/
|
*/
|
||||||
@ -630,7 +631,8 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* IYUUAutoReseed做种客户端转移
|
* IYUUAutoReseed做种客户端转移
|
||||||
*/
|
*/
|
||||||
public static function move($hashArray = array()){
|
public static function move($hashArray = array())
|
||||||
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
$sites = array();
|
$sites = array();
|
||||||
// 前置过滤:2020年1月26日15:52:41
|
// 前置过滤:2020年1月26日15:52:41
|
||||||
@ -655,14 +657,14 @@ class AutoReseed
|
|||||||
#self::$wechatMsg['sitesCount'] = count($sites);
|
#self::$wechatMsg['sitesCount'] = count($sites);
|
||||||
// 按客户端移动 开始
|
// 按客户端移动 开始
|
||||||
foreach (self::$links as $k => $v) {
|
foreach (self::$links as $k => $v) {
|
||||||
if (self::$move!=null && self::$move[0] == $k){
|
if (self::$move!=null && self::$move[0] == $k) {
|
||||||
echo "clients_".$k."是目标转移客户端,避免冲突,已跳过!".PHP_EOL.PHP_EOL;
|
echo "clients_".$k."是目标转移客户端,避免冲突,已跳过!".PHP_EOL.PHP_EOL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (empty($resArray['clients_'.$k])) {
|
if (empty($resArray['clients_'.$k])) {
|
||||||
echo "clients_".$k."没有查询到可转移数据".PHP_EOL.PHP_EOL;
|
echo "clients_".$k."没有查询到可转移数据".PHP_EOL.PHP_EOL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$infohash_Dir = $move = array();
|
$infohash_Dir = $move = array();
|
||||||
// info_hash与下载目录对应表
|
// info_hash与下载目录对应表
|
||||||
$infohash_Dir = self::$links[$k]['hash'];
|
$infohash_Dir = self::$links[$k]['hash'];
|
||||||
@ -693,13 +695,13 @@ class AutoReseed
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// cookie检测
|
// cookie检测
|
||||||
if ( in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie']) ) {
|
if (in_array($siteName, self::$cookieCheck) && empty($configALL[$siteName]['cookie'])) {
|
||||||
echo '-------因当前' .$siteName. '站点未设置cookie,已跳过!!' .PHP_EOL.PHP_EOL;
|
echo '-------因当前' .$siteName. '站点未设置cookie,已跳过!!' .PHP_EOL.PHP_EOL;
|
||||||
#self::$wechatMsg['reseedSkip']++;
|
#self::$wechatMsg['reseedSkip']++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 流控检测
|
// 流控检测
|
||||||
if ( isset($configALL[$siteName]['limit']) ) {
|
if (isset($configALL[$siteName]['limit'])) {
|
||||||
echo "-------因当前" .$siteName. "站点触发流控,已跳过!! {$_url}".PHP_EOL.PHP_EOL;
|
echo "-------因当前" .$siteName. "站点触发流控,已跳过!! {$_url}".PHP_EOL.PHP_EOL;
|
||||||
// 流控日志
|
// 流控日志
|
||||||
if ($siteName == 'hdchina') {
|
if ($siteName == 'hdchina') {
|
||||||
@ -711,13 +713,13 @@ class AutoReseed
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 历史转移检测
|
// 历史转移检测
|
||||||
if ( is_file(self::$cacheMove . $info_hash.'.txt') ) {
|
if (is_file(self::$cacheMove . $info_hash.'.txt')) {
|
||||||
echo '-------当前种子上次已成功转移,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
echo '-------当前种子上次已成功转移,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
||||||
#self::$wechatMsg['reseedPass']++;
|
#self::$wechatMsg['reseedPass']++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 不转移的站点检测
|
// 不转移的站点检测
|
||||||
if ( in_array($siteName, self::$noMove) ) {
|
if (in_array($siteName, self::$noMove)) {
|
||||||
echo '-------已跳过不转移的站点 ' .$siteName. '!! ' .PHP_EOL.PHP_EOL;
|
echo '-------已跳过不转移的站点 ' .$siteName. '!! ' .PHP_EOL.PHP_EOL;
|
||||||
#self::$wechatMsg['reseedSkip']++;
|
#self::$wechatMsg['reseedSkip']++;
|
||||||
continue;
|
continue;
|
||||||
@ -781,7 +783,7 @@ class AutoReseed
|
|||||||
echo "种子URL已推送给下载器,下载器正在下载种子...".PHP_EOL;
|
echo "种子URL已推送给下载器,下载器正在下载种子...".PHP_EOL;
|
||||||
// 实际路径与相对路径之间互转
|
// 实际路径与相对路径之间互转
|
||||||
$downloadDir = self::pathReplace($downloadDir);
|
$downloadDir = self::pathReplace($downloadDir);
|
||||||
if ( is_null($downloadDir) ) {
|
if (is_null($downloadDir)) {
|
||||||
die("全局配置的move数组内,type配置错误,请重新配置!!!".PHP_EOL);
|
die("全局配置的move数组内,type配置错误,请重新配置!!!".PHP_EOL);
|
||||||
}
|
}
|
||||||
$ret = false;
|
$ret = false;
|
||||||
@ -823,13 +825,16 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* 过滤已转移的种子hash
|
* 过滤已转移的种子hash
|
||||||
*/
|
*/
|
||||||
public static function hashFilter(&$hash = array()){
|
public static function hashFilter(&$hash = array())
|
||||||
|
{
|
||||||
foreach ($hash as $client => $json) {
|
foreach ($hash as $client => $json) {
|
||||||
$data = array();
|
$data = array();
|
||||||
$data = json_decode($json,true);
|
$data = json_decode($json, true);
|
||||||
if (empty($data)) continue;
|
if (empty($data)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ($data as $key => $info_hash) {
|
foreach ($data as $key => $info_hash) {
|
||||||
if ( is_file(self::$cacheMove . $info_hash.'.txt') ) {
|
if (is_file(self::$cacheMove . $info_hash.'.txt')) {
|
||||||
echo '-------当前种子上次已成功转移,前置过滤已跳过! ' .PHP_EOL.PHP_EOL;
|
echo '-------当前种子上次已成功转移,前置过滤已跳过! ' .PHP_EOL.PHP_EOL;
|
||||||
unset($data[$key]);
|
unset($data[$key]);
|
||||||
}
|
}
|
||||||
@ -837,7 +842,7 @@ class AutoReseed
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
$data = array_values($data);
|
$data = array_values($data);
|
||||||
}
|
}
|
||||||
$hash[$client] = json_encode($data,JSON_UNESCAPED_UNICODE);
|
$hash[$client] = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
@ -852,7 +857,7 @@ class AutoReseed
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 1: // 减
|
case 1: // 减
|
||||||
foreach ($pathArray as $key => $val) {
|
foreach ($pathArray as $key => $val) {
|
||||||
if ( strpos($path, $key)===0 ) {
|
if (strpos($path, $key)===0) {
|
||||||
return substr($path, strlen($key));
|
return substr($path, strlen($key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -860,14 +865,14 @@ class AutoReseed
|
|||||||
break;
|
break;
|
||||||
case 2: // 加
|
case 2: // 加
|
||||||
foreach ($pathArray as $key => $val) {
|
foreach ($pathArray as $key => $val) {
|
||||||
if ( strpos($path, $key)===0 ) {
|
if (strpos($path, $key)===0) {
|
||||||
return $val . $path;
|
return $val . $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: // 替换
|
case 3: // 替换
|
||||||
foreach ($pathArray as $key => $val) {
|
foreach ($pathArray as $key => $val) {
|
||||||
if ( strpos($path, $key)===0 ) {
|
if (strpos($path, $key)===0) {
|
||||||
return $val . substr($path, strlen($key));
|
return $val . substr($path, strlen($key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -882,7 +887,8 @@ class AutoReseed
|
|||||||
/**
|
/**
|
||||||
* 获取站点种子的URL
|
* 获取站点种子的URL
|
||||||
*/
|
*/
|
||||||
public static function getTorrentUrl($site = '',$_url = ''){
|
public static function getTorrentUrl($site = '', $_url = '')
|
||||||
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
switch ($site) {
|
switch ($site) {
|
||||||
case 'ttg':
|
case 'ttg':
|
||||||
|
3
iyuu.php
3
iyuu.php
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/init.php';
|
require_once __DIR__ . '/init.php';
|
||||||
use IYUU\AutoReseed;
|
use IYUU\AutoReseed;
|
||||||
|
|
||||||
echo microtime(true).' IYUU自动辅种正在初始化...'.PHP_EOL;
|
echo microtime(true).' IYUU自动辅种正在初始化...'.PHP_EOL;
|
||||||
AutoReseed::init();
|
AutoReseed::init();
|
||||||
$hashArray = AutoReseed::get();
|
$hashArray = AutoReseed::get();
|
||||||
AutoReseed::call($hashArray);
|
AutoReseed::call($hashArray);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user