mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-06-12 19:58:56 +00:00
移除失效站点信息,优化代码
This commit is contained in:
@ -18,7 +18,7 @@ ARG app_env=prod
|
|||||||
|
|
||||||
ENV APP_ENV=${app_env:-"prod"} \
|
ENV APP_ENV=${app_env:-"prod"} \
|
||||||
TIMEZONE=${timezone:-"Asia/Shanghai"} \
|
TIMEZONE=${timezone:-"Asia/Shanghai"} \
|
||||||
cron="8 11 * * 0"
|
cron="9 11 * * 0"
|
||||||
|
|
||||||
##
|
##
|
||||||
# ---------- building ----------
|
# ---------- building ----------
|
||||||
|
@ -13,7 +13,7 @@ use IYUU\Library\Table;
|
|||||||
class AutoReseed
|
class AutoReseed
|
||||||
{
|
{
|
||||||
// 版本号
|
// 版本号
|
||||||
const VER = '1.10.8';
|
const VER = '1.10.9';
|
||||||
// RPC连接
|
// RPC连接
|
||||||
private static $links = [];
|
private static $links = [];
|
||||||
// 客户端配置
|
// 客户端配置
|
||||||
@ -81,7 +81,7 @@ class AutoReseed
|
|||||||
|
|
||||||
// 显示支持站点列表
|
// 显示支持站点列表
|
||||||
self::ShowTableSites();
|
self::ShowTableSites();
|
||||||
self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array();
|
self::$clients = empty($configALL['default']['clients']) ? [] : $configALL['default']['clients'];
|
||||||
|
|
||||||
// 递归删除上次历史记录
|
// 递归删除上次历史记录
|
||||||
IFile::rmdir(self::$cacheDir, true);
|
IFile::rmdir(self::$cacheDir, true);
|
||||||
@ -105,12 +105,12 @@ class AutoReseed
|
|||||||
'【IYUU自动辅种交流】QQ群:859882209、931954050'.PHP_EOL,
|
'【IYUU自动辅种交流】QQ群:859882209、931954050'.PHP_EOL,
|
||||||
'正在连接IYUUAutoReseed服务器,查询支持列表……'.PHP_EOL
|
'正在连接IYUUAutoReseed服务器,查询支持列表……'.PHP_EOL
|
||||||
];
|
];
|
||||||
foreach ($list as $v) {
|
array_walk($list,function ($v, $k){
|
||||||
echo $v.PHP_EOL;
|
echo $v.PHP_EOL;
|
||||||
}
|
});
|
||||||
$res = self::$curl->get(self::$apiUrl.self::$endpoints['sites'].'?sign='.Oauth::getSign().'&version='.self::VER);
|
$res = self::$curl->get(self::$apiUrl.self::$endpoints['sites'].'?sign='.Oauth::getSign().'&version='.self::VER);
|
||||||
$rs = json_decode($res->response, true);
|
$rs = json_decode($res->response, true);
|
||||||
$sites = isset($rs['data']['sites']) && $rs['data']['sites'] ? $rs['data']['sites'] : [];
|
$sites = empty($rs['data']['sites']) ? [] : $rs['data']['sites'];
|
||||||
// 数据写入本地
|
// 数据写入本地
|
||||||
if (empty($sites)) {
|
if (empty($sites)) {
|
||||||
if (!empty($rs['msg'])) {
|
if (!empty($rs['msg'])) {
|
||||||
@ -118,12 +118,7 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
die('网络故障或远端服务器无响应,请稍后再试!!!');
|
die('网络故障或远端服务器无响应,请稍后再试!!!');
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$sites = array_column($sites, null, 'id');
|
self::$sites = array_column($sites, null, 'id');
|
||||||
$json = array_column($sites, null, 'site');
|
|
||||||
ksort($json);
|
|
||||||
$sitesConfig = ROOT_PATH.DS.'config'.DS.'sites.json';
|
|
||||||
file_put_contents($sitesConfig, \json_encode($json, JSON_UNESCAPED_UNICODE));
|
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$i = $j = $k = 0; // i列、j序号、k行
|
$i = $j = $k = 0; // i列、j序号、k行
|
||||||
@ -142,6 +137,12 @@ class AutoReseed
|
|||||||
$table = new Table();
|
$table = new Table();
|
||||||
$table->setRows($data);
|
$table->setRows($data);
|
||||||
echo($table->render());
|
echo($table->render());
|
||||||
|
|
||||||
|
// 生成IYUUPTT使用的JSON
|
||||||
|
$json = array_column($sites, null, 'site');
|
||||||
|
ksort($json);
|
||||||
|
$sitesConfig = ROOT_PATH.DS.'config'.DS.'sites.json';
|
||||||
|
file_put_contents($sitesConfig, \json_encode($json, JSON_UNESCAPED_UNICODE));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 连接远端RPC下载器
|
* 连接远端RPC下载器
|
||||||
@ -169,14 +170,17 @@ class AutoReseed
|
|||||||
self::$move = array($k,$v['move']);
|
self::$move = array($k,$v['move']);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
die('[连接错误] ' . $e->getMessage() . PHP_EOL);
|
die('[连接错误] '. $v['host'] . $e->getMessage() . PHP_EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 添加下载任务
|
* @brief 添加下载任务
|
||||||
|
* @param $rpcKey
|
||||||
* @param string $torrent 种子元数据
|
* @param string $torrent 种子元数据
|
||||||
* @param string $save_path 保存路径
|
* @param string $save_path 保存路径
|
||||||
|
* @param array $extra_options
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function add($rpcKey, $torrent, $save_path = '', $extra_options = array())
|
public static function add($rpcKey, $torrent, $save_path = '', $extra_options = array())
|
||||||
@ -273,7 +277,7 @@ class AutoReseed
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 过滤无需辅种的客户端
|
// 过滤无需辅种的客户端
|
||||||
if (self::$move!==null && self::$move[0]!=$k && self::$move[1]==2) {
|
if ((self::$move !== null) && (self::$move[0] != $k) && (self::$move[1] == 2)) {
|
||||||
echo "clients_".$k." 根据设置无需辅种,已跳过!";
|
echo "clients_".$k." 根据设置无需辅种,已跳过!";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -282,7 +286,7 @@ class AutoReseed
|
|||||||
if (empty($hashArray)) {
|
if (empty($hashArray)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self::backup('clients_'.$k, $hashArray);
|
|
||||||
$infohash_Dir = $hashArray['hashString']; // 哈希目录对应字典
|
$infohash_Dir = $hashArray['hashString']; // 哈希目录对应字典
|
||||||
unset($hashArray['hashString']);
|
unset($hashArray['hashString']);
|
||||||
// 签名
|
// 签名
|
||||||
@ -291,11 +295,11 @@ class AutoReseed
|
|||||||
$hashArray['version'] = self::VER;
|
$hashArray['version'] = self::VER;
|
||||||
// 写请求日志
|
// 写请求日志
|
||||||
wlog($hashArray, 'hashString'.$k);
|
wlog($hashArray, 'hashString'.$k);
|
||||||
self::$wechatMsg['hashCount'] +=count($infohash_Dir);
|
self::$wechatMsg['hashCount'] += count($infohash_Dir);
|
||||||
// 此处优化大于一万条做种时,设置超时
|
// 此处优化大于一万条做种时,设置超时
|
||||||
if (count($infohash_Dir) > 5000) {
|
if (count($infohash_Dir) > 5000) {
|
||||||
$connecttimeout = isset($configALL['default']['CONNECTTIMEOUT']) && $configALL['default']['CONNECTTIMEOUT']>60 ? $configALL['default']['CONNECTTIMEOUT'] : 60;
|
$connecttimeout = isset($configALL['default']['CONNECTTIMEOUT']) && $configALL['default']['CONNECTTIMEOUT'] > 60 ? $configALL['default']['CONNECTTIMEOUT'] : 60;
|
||||||
$timeout = isset($configALL['default']['TIMEOUT']) && $configALL['default']['TIMEOUT']>600 ? $configALL['default']['TIMEOUT'] : 600;
|
$timeout = isset($configALL['default']['TIMEOUT']) && $configALL['default']['TIMEOUT'] > 600 ? $configALL['default']['TIMEOUT'] : 600;
|
||||||
self::$curl->setOpt(CURLOPT_CONNECTTIMEOUT, $connecttimeout);
|
self::$curl->setOpt(CURLOPT_CONNECTTIMEOUT, $connecttimeout);
|
||||||
self::$curl->setOpt(CURLOPT_TIMEOUT, $timeout);
|
self::$curl->setOpt(CURLOPT_TIMEOUT, $timeout);
|
||||||
}
|
}
|
||||||
@ -614,6 +618,7 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
// 种子目录:脚本要能够读取到
|
// 种子目录:脚本要能够读取到
|
||||||
$path = self::$links[$k]['BT_backup'];
|
$path = self::$links[$k]['BT_backup'];
|
||||||
|
$torrentPath = '';
|
||||||
// 待删除种子
|
// 待删除种子
|
||||||
$torrentDelete = '';
|
$torrentDelete = '';
|
||||||
// 获取种子原文件的实际路径
|
// 获取种子原文件的实际路径
|
||||||
@ -637,7 +642,6 @@ class AutoReseed
|
|||||||
$torrentDelete = $info_hash;
|
$torrentDelete = $info_hash;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
# code...
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!is_file($torrentPath)) {
|
if (!is_file($torrentPath)) {
|
||||||
@ -659,7 +663,6 @@ class AutoReseed
|
|||||||
if (isset($configALL['default']['move']['skip_check']) && $configALL['default']['move']['skip_check'] === 1) {
|
if (isset($configALL['default']['move']['skip_check']) && $configALL['default']['move']['skip_check'] === 1) {
|
||||||
$extra_options['skip_checking'] = "true"; //转移成功,跳校验
|
$extra_options['skip_checking'] = "true"; //转移成功,跳校验
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加转移任务:成功返回:true
|
// 添加转移任务:成功返回:true
|
||||||
@ -725,7 +728,7 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
// 历史添加检测
|
// 历史添加检测
|
||||||
if (is_file(self::$cacheHash . $info_hash.'.txt')) {
|
if (is_file(self::$cacheHash . $info_hash.'.txt')) {
|
||||||
echo '-------当前种子上次辅种已成功添加,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
echo '-------当前种子上次辅种已成功添加【'.self::$cacheHash . $info_hash.'】,已跳过! '.$_url.PHP_EOL.PHP_EOL;
|
||||||
self::$wechatMsg['reseedPass']++;
|
self::$wechatMsg['reseedPass']++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -795,14 +798,16 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
return empty($infohash_Dir) ? true : false;
|
return empty($infohash_Dir) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实际路径与相对路径之间互相转换
|
* 实际路径与相对路径之间互相转换
|
||||||
|
* @param string $path
|
||||||
* @return string | null string转换成功
|
* @return string | null string转换成功
|
||||||
*/
|
*/
|
||||||
private static function pathReplace($path = '')
|
private static function pathReplace($path = '')
|
||||||
{
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
$type = $configALL['default']['move']['type'];
|
$type = intval($configALL['default']['move']['type']);
|
||||||
$pathArray = $configALL['default']['move']['path'];
|
$pathArray = $configALL['default']['move']['path'];
|
||||||
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@ -844,11 +849,13 @@ class AutoReseed
|
|||||||
global $configALL;
|
global $configALL;
|
||||||
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
||||||
// 转移过滤器、选择器 David/2020年7月11日
|
// 转移过滤器、选择器 David/2020年7月11日
|
||||||
$path_filter = isset($configALL['default']['move']['path_filter']) && !empty($configALL['default']['move']['path_filter']) ? $configALL['default']['move']['path_filter'] : null;
|
$path_filter = !empty($configALL['default']['move']['path_filter']) ? $configALL['default']['move']['path_filter'] : null;
|
||||||
$path_selector = isset($configALL['default']['move']['path_selector']) && !empty($configALL['default']['move']['path_selector']) ? $configALL['default']['move']['path_selector'] : null;
|
$path_selector = !empty($configALL['default']['move']['path_selector']) ? $configALL['default']['move']['path_selector'] : null;
|
||||||
if (\is_null($path_filter) && \is_null($path_selector)) {
|
if (\is_null($path_filter) && \is_null($path_selector)) {
|
||||||
return false;
|
return false;
|
||||||
} elseif (\is_null($path_filter)) {
|
}
|
||||||
|
|
||||||
|
if (\is_null($path_filter)) {
|
||||||
//选择器
|
//选择器
|
||||||
if (\is_array($path_selector)) {
|
if (\is_array($path_selector)) {
|
||||||
foreach ($path_selector as $pathName) {
|
foreach ($path_selector as $pathName) {
|
||||||
@ -909,7 +916,7 @@ class AutoReseed
|
|||||||
}
|
}
|
||||||
if (empty($configALL[$site]['url_join'])) {
|
if (empty($configALL[$site]['url_join'])) {
|
||||||
$configALL[$site]['url_join'] = array();
|
$configALL[$site]['url_join'] = array();
|
||||||
if (in_array($site, array('m-team','mocat','hdbd'))) {
|
if (in_array($site, array('m-team','hdbd'))) {
|
||||||
if (isset($configALL[$site]['ip_type'])) {
|
if (isset($configALL[$site]['ip_type'])) {
|
||||||
$configALL[$site]['url_join'][] = $configALL[$site]['ip_type'].'=1';
|
$configALL[$site]['url_join'][] = $configALL[$site]['ip_type'].'=1';
|
||||||
}
|
}
|
||||||
|
@ -11,34 +11,38 @@ class Oauth
|
|||||||
// 合作的站点
|
// 合作的站点
|
||||||
public static $sites = ['ourbits','hddolby','hdhome','pthome','chdbits'];
|
public static $sites = ['ourbits','hddolby','hdhome','pthome','chdbits'];
|
||||||
// 爱语飞飞token
|
// 爱语飞飞token
|
||||||
public static $token = '';
|
private static $token = '';
|
||||||
// 合作站点用户id
|
// 合作站点用户id
|
||||||
public static $user_id = 0;
|
private static $user_id = 0;
|
||||||
// 合作站点密钥
|
// 合作站点密钥
|
||||||
public static $passkey = '';
|
private static $passkey = '';
|
||||||
// 合作站名字
|
// 合作站名字
|
||||||
public static $site = '';
|
private static $site = '';
|
||||||
// 登录缓存路径
|
// 登录缓存路径
|
||||||
public static $SiteLoginCache = ROOT_PATH.DS.'config'.DS.'siteLoginCache_{}.json';
|
private static $SiteLoginCache = ROOT_PATH.DS.'config'.DS.'siteLoginCache_{}.json';
|
||||||
/**
|
/**
|
||||||
* 从配置文件内读取爱语飞飞token作为鉴权参数
|
* 从配置文件内读取爱语飞飞token作为鉴权参数
|
||||||
*/
|
*/
|
||||||
public static function getSign()
|
public static function getSign()
|
||||||
{
|
{
|
||||||
global $configALL;
|
global $configALL;
|
||||||
// 爱语飞飞
|
$token = empty($configALL['iyuu.cn']) ? '' : $configALL['iyuu.cn'];
|
||||||
$token = isset($configALL['iyuu.cn']) && $configALL['iyuu.cn'] ? $configALL['iyuu.cn'] : '';
|
if (empty($token) || strlen($token) < 46) {
|
||||||
if (empty($token) || strlen($token)<46) {
|
echo "缺少辅种接口请求参数:爱语飞飞token ".PHP_EOL;
|
||||||
echo "缺少辅种接口请求参数:爱语飞飞token \n";
|
echo "请访问https://iyuu.cn 用微信扫码申请,并填入配置文件config.php内。".PHP_EOL.PHP_EOL;
|
||||||
echo "请访问https://iyuu.cn 用微信扫码申请,并填入配置文件config.php内。\n\n";
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户注册与登录
|
* 用户注册与登录
|
||||||
* 作用:在服务器端实现微信用户与合作站点用户id的关联
|
* 作用:在服务器端实现微信用户与合作站点用户id的关联
|
||||||
* 参数:爱语飞飞token + 合作站点用户id + sha1(合作站点密钥passkey) + 合作站点标识
|
* 参数:爱语飞飞token + 合作站点用户id + sha1(合作站点密钥passkey) + 合作站点标识
|
||||||
|
* @param string $apiUrl
|
||||||
|
* @param array $sites
|
||||||
|
* @return bool
|
||||||
|
* @throws \ErrorException
|
||||||
*/
|
*/
|
||||||
public static function login($apiUrl = '', $sites = array())
|
public static function login($apiUrl = '', $sites = array())
|
||||||
{
|
{
|
||||||
|
@ -393,8 +393,9 @@ function sign($timestamp)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 分离token中的用户uid
|
* @brief 分离token中的用户uid
|
||||||
* token算法:IYUU + uid + T + sha1(openid+time+盐)
|
* @desc token算法:IYUU + uid + T + sha1(openid+time+盐)
|
||||||
* @param string $token 用户请求token
|
* @param string $token 用户请求token
|
||||||
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
function getUid($token)
|
function getUid($token)
|
||||||
{
|
{
|
||||||
|
@ -177,23 +177,6 @@ return array(
|
|||||||
'url_replace' => array(),
|
'url_replace' => array(),
|
||||||
'url_join' => array(),
|
'url_join' => array(),
|
||||||
),
|
),
|
||||||
// MoeCat
|
|
||||||
'moecat' => array(
|
|
||||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
|
||||||
'cookie' => '',
|
|
||||||
// 如果需要自动辅种,必须配置
|
|
||||||
'passkey' => '',
|
|
||||||
'id' => 0, // 用户ID(不是用户名)
|
|
||||||
'url_replace' => array(),
|
|
||||||
'url_join' => array(
|
|
||||||
//'ipv6=1', // 种子Tracker的IP地址选择 可选:ipv4,ipv6
|
|
||||||
'https=1',
|
|
||||||
),
|
|
||||||
'limitRule' => array(
|
|
||||||
'count' => 20, // 每次辅种20个
|
|
||||||
'sleep' => 15, // 最少休眠15秒
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// m-team
|
// m-team
|
||||||
'm-team' => array(
|
'm-team' => array(
|
||||||
// 14.m-team的cookie 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
// 14.m-team的cookie 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||||
|
@ -5,5 +5,4 @@ echo $pwddir
|
|||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
git fetch --all
|
git fetch --all
|
||||||
git reset --hard origin/master
|
git reset --hard origin/master
|
||||||
git pull
|
|
||||||
php ./iyuu.php
|
php ./iyuu.php
|
Reference in New Issue
Block a user