mirror of
https://gitee.com/ledc/IYUUAutoReseed
synced 2025-08-24 15:04:50 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
84f75ea443 | ||
|
715be0e7eb | ||
|
6eebc7d26c | ||
|
30410735af | ||
|
99a2894f37 | ||
|
13b176c4a1 | ||
|
afca458acc | ||
|
b8b05ff3bf | ||
|
d402d30aac | ||
|
11c976d2c0 | ||
|
630dc3af92 | ||
|
463e45ee38 | ||
|
b046ecc75f |
@@ -18,7 +18,7 @@ ARG app_env=prod
|
||||
|
||||
ENV APP_ENV=${app_env:-"prod"} \
|
||||
TIMEZONE=${timezone:-"Asia/Shanghai"} \
|
||||
cron="0 10 * * 0"
|
||||
cron="9 11 * * 0"
|
||||
|
||||
##
|
||||
# ---------- building ----------
|
||||
|
@@ -13,7 +13,7 @@ use IYUU\Library\Table;
|
||||
class AutoReseed
|
||||
{
|
||||
// 版本号
|
||||
const VER = '1.10.4';
|
||||
const VER = '1.10.9';
|
||||
// RPC连接
|
||||
private static $links = [];
|
||||
// 客户端配置
|
||||
@@ -34,8 +34,8 @@ class AutoReseed
|
||||
'login' => '/user/login',
|
||||
'sites' => '/api/sites',
|
||||
'infohash'=> '/api/infohash',
|
||||
'notify' => '/api/notify',
|
||||
'hash' => '/api/hash',
|
||||
'notify' => '/api/notify',
|
||||
);
|
||||
// curl
|
||||
private static $curl = null;
|
||||
@@ -68,8 +68,9 @@ class AutoReseed
|
||||
public static function init()
|
||||
{
|
||||
global $configALL;
|
||||
echo "正在初始化运行参数,版本号:".self::VER.PHP_EOL;
|
||||
sleep(mt_rand(1, 3));
|
||||
echo '正在初始化运行参数,版本号:'.self::VER.PHP_EOL;
|
||||
echo '当前时间:'.date('Y-m-d H:i:s').PHP_EOL;
|
||||
//sleep(mt_rand(1, 5));
|
||||
self::backup('config', $configALL);
|
||||
self::$curl = new Curl();
|
||||
self::$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
|
||||
@@ -80,10 +81,7 @@ class AutoReseed
|
||||
|
||||
// 显示支持站点列表
|
||||
self::ShowTableSites();
|
||||
self::$clients = isset($configALL['default']['clients']) && $configALL['default']['clients'] ? $configALL['default']['clients'] : array();
|
||||
if (empty(self::$clients)) {
|
||||
die('全局客户端为空!');
|
||||
}
|
||||
self::$clients = empty($configALL['default']['clients']) ? [] : $configALL['default']['clients'];
|
||||
|
||||
// 递归删除上次历史记录
|
||||
IFile::rmdir(self::$cacheDir, true);
|
||||
@@ -107,28 +105,21 @@ class AutoReseed
|
||||
'【IYUU自动辅种交流】QQ群:859882209、931954050'.PHP_EOL,
|
||||
'正在连接IYUUAutoReseed服务器,查询支持列表……'.PHP_EOL
|
||||
];
|
||||
foreach ($list as $value) {
|
||||
echo $value.PHP_EOL;
|
||||
}
|
||||
array_walk($list,function ($v, $k){
|
||||
echo $v.PHP_EOL;
|
||||
});
|
||||
$res = self::$curl->get(self::$apiUrl.self::$endpoints['sites'].'?sign='.Oauth::getSign().'&version='.self::VER);
|
||||
$rs = json_decode($res->response, true);
|
||||
$sites = isset($rs['data']['sites']) && $rs['data']['sites'] ? $rs['data']['sites'] : false;
|
||||
$sites = empty($rs['data']['sites']) ? [] : $rs['data']['sites'];
|
||||
// 数据写入本地
|
||||
if ($sites) {
|
||||
self::$sites = array_column($sites, null, 'id');
|
||||
$json = array_column($sites, null, 'site');
|
||||
ksort($json);
|
||||
$json = json_encode($json, JSON_UNESCAPED_UNICODE);
|
||||
$myfile = ROOT_PATH.DS.'config'.DS.'sites.json';
|
||||
$file_pointer = @fopen($myfile, "w");
|
||||
$worldsnum = @fwrite($file_pointer, $json);
|
||||
@fclose($file_pointer);
|
||||
} else {
|
||||
if (isset($rs['msg']) && $rs['msg']) {
|
||||
if (empty($sites)) {
|
||||
if (!empty($rs['msg'])) {
|
||||
die($rs['msg'].PHP_EOL);
|
||||
}
|
||||
die('远端服务器无响应,请稍后再试!!!');
|
||||
die('网络故障或远端服务器无响应,请稍后再试!!!');
|
||||
}
|
||||
self::$sites = array_column($sites, null, 'id');
|
||||
|
||||
$data = [];
|
||||
$i = $j = $k = 0; // i列、j序号、k行
|
||||
foreach ($sites as $v) {
|
||||
@@ -146,6 +137,12 @@ class AutoReseed
|
||||
$table = new Table();
|
||||
$table->setRows($data);
|
||||
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下载器
|
||||
@@ -167,20 +164,23 @@ class AutoReseed
|
||||
self::$links[$k]['BT_backup'] = isset($v['BT_backup']) && $v['BT_backup'] ? $v['BT_backup'] : '';
|
||||
self::$links[$k]['root_folder'] = isset($v['root_folder']) ? $v['root_folder'] : 1;
|
||||
$result = $client->status();
|
||||
print $v['type'].':'.$v['host']." Rpc连接 [{$result}] \n";
|
||||
print $v['type'].':'.$v['host']." Rpc连接 [{$result}]".PHP_EOL;
|
||||
// 检查转移做种 (self::$move为空,移动配置为真)
|
||||
if (is_null(self::$move) && isset($v['move']) && $v['move']) {
|
||||
if (is_null(self::$move) && !empty($v['move'])) {
|
||||
self::$move = array($k,$v['move']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
die('[连接错误] ' . $e->getMessage() . PHP_EOL);
|
||||
die('[连接错误] '. $v['host'] . $e->getMessage() . PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加下载任务
|
||||
* @param $rpcKey
|
||||
* @param string $torrent 种子元数据
|
||||
* @param string $save_path 保存路径
|
||||
* @param array $extra_options
|
||||
* @return bool
|
||||
*/
|
||||
public static function add($rpcKey, $torrent, $save_path = '', $extra_options = array())
|
||||
@@ -197,19 +197,14 @@ class AutoReseed
|
||||
case 'transmission':
|
||||
$extra_options['paused'] = isset($extra_options['paused']) ? $extra_options['paused'] : true;
|
||||
if ($is_url) {
|
||||
$result = self::$links[$rpcKey]['rpc']->add($torrent, $save_path, $extra_options); // 种子URL添加下载任务
|
||||
$result = self::$links[$rpcKey]['rpc']->add($torrent, $save_path, $extra_options); // URL添加
|
||||
} else {
|
||||
$result = self::$links[$rpcKey]['rpc']->add_metainfo($torrent, $save_path, $extra_options); // 种子元数据添加下载任务
|
||||
$result = self::$links[$rpcKey]['rpc']->add_metainfo($torrent, $save_path, $extra_options); // 元数据添加
|
||||
}
|
||||
if (isset($result['result']) && $result['result'] == 'success') {
|
||||
$id = $name = '';
|
||||
if (isset($result['arguments']['torrent-duplicate'])) {
|
||||
$id = $result['arguments']['torrent-duplicate']['id'];
|
||||
$name = $result['arguments']['torrent-duplicate']['name'];
|
||||
} elseif (isset($result['arguments']['torrent-added'])) {
|
||||
$id = $result['arguments']['torrent-added']['id'];
|
||||
$name = $result['arguments']['torrent-added']['name'];
|
||||
}
|
||||
$_key = isset($result['arguments']['torrent-added']) ? 'torrent-added' : 'torrent-duplicate';
|
||||
$id = $result['arguments'][$_key]['id'];
|
||||
$name = $result['arguments'][$_key]['name'];
|
||||
print "名字:" .$name . PHP_EOL;
|
||||
print "********RPC添加下载任务成功 [" .$result['result']. "] (id=" .$id. ")".PHP_EOL.PHP_EOL;
|
||||
return true;
|
||||
@@ -233,12 +228,11 @@ class AutoReseed
|
||||
// 是否创建根目录
|
||||
$extra_options['root_folder'] = self::$links[$rpcKey]['root_folder'] ? 'true' : 'false';
|
||||
if ($is_url) {
|
||||
$result = self::$links[$rpcKey]['rpc']->add($torrent, $save_path, $extra_options); // 种子URL添加下载任务
|
||||
$result = self::$links[$rpcKey]['rpc']->add($torrent, $save_path, $extra_options); // URL添加
|
||||
} else {
|
||||
$extra_options['name'] = 'torrents';
|
||||
$rand = mt_rand(10, 42949672);
|
||||
$extra_options['filename'] = intval($rand).'.torrent';
|
||||
$result = self::$links[$rpcKey]['rpc']->add_metainfo($torrent, $save_path, $extra_options); // 种子元数据添加下载任务
|
||||
$extra_options['filename'] = time().'.torrent';
|
||||
$result = self::$links[$rpcKey]['rpc']->add_metainfo($torrent, $save_path, $extra_options); // 元数据添加
|
||||
}
|
||||
if ($result === 'Ok.') {
|
||||
print "********RPC添加下载任务成功 [{$result}]".PHP_EOL.PHP_EOL;
|
||||
@@ -283,18 +277,17 @@ class AutoReseed
|
||||
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." 根据设置无需辅种,已跳过!";
|
||||
continue;
|
||||
}
|
||||
echo "正在从下载器 clients_".$k." 获取种子哈希……".PHP_EOL;
|
||||
$hashArray = self::$links[$k]['rpc']->getList();
|
||||
if (empty($hashArray)) {
|
||||
// 失败
|
||||
continue;
|
||||
}
|
||||
self::backup('clients_'.$k, $hashArray);
|
||||
$infohash_Dir = $hashArray['hashString'];
|
||||
|
||||
$infohash_Dir = $hashArray['hashString']; // 哈希目录对应字典
|
||||
unset($hashArray['hashString']);
|
||||
// 签名
|
||||
$hashArray['sign'] = Oauth::getSign();
|
||||
@@ -302,11 +295,11 @@ class AutoReseed
|
||||
$hashArray['version'] = self::VER;
|
||||
// 写请求日志
|
||||
wlog($hashArray, 'hashString'.$k);
|
||||
self::$wechatMsg['hashCount'] +=count($infohash_Dir);
|
||||
self::$wechatMsg['hashCount'] += count($infohash_Dir);
|
||||
// 此处优化大于一万条做种时,设置超时
|
||||
if (count($infohash_Dir) > 5000) {
|
||||
$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;
|
||||
$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;
|
||||
self::$curl->setOpt(CURLOPT_CONNECTTIMEOUT, $connecttimeout);
|
||||
self::$curl->setOpt(CURLOPT_TIMEOUT, $timeout);
|
||||
}
|
||||
@@ -332,8 +325,7 @@ class AutoReseed
|
||||
}
|
||||
// 遍历当前客户端可辅种数据
|
||||
foreach ($data as $info_hash => $reseed) {
|
||||
// 可辅种信息用哈希对应目录
|
||||
$downloadDir = $infohash_Dir[$info_hash];
|
||||
$downloadDir = $infohash_Dir[$info_hash]; // 辅种目录
|
||||
foreach ($reseed['torrent'] as $id => $value) {
|
||||
// 匹配的辅种数据累加
|
||||
self::$wechatMsg['reseedCount']++;
|
||||
@@ -351,10 +343,10 @@ class AutoReseed
|
||||
$siteName = self::$sites[$sid]['site'];
|
||||
// 错误通知
|
||||
self::setNotify($siteName, $sid, $torrent_id);
|
||||
// 种子页规则
|
||||
$download_page = str_replace('{}', $torrent_id, self::$sites[$sid]['download_page']);
|
||||
// 协议
|
||||
$protocol = self::$sites[$sid]['is_https'] == 0 ? 'http://' : 'https://';
|
||||
// 种子页规则
|
||||
$download_page = str_replace('{}', $torrent_id, self::$sites[$sid]['download_page']);
|
||||
|
||||
// 临时种子连接(会写入辅种日志)
|
||||
$_url = $protocol . self::$sites[$sid]['base_url']. '/' .$download_page;
|
||||
@@ -498,8 +490,10 @@ class AutoReseed
|
||||
if ($reseedPass) {
|
||||
continue;
|
||||
}
|
||||
$downloadUrl = $_url;
|
||||
} else {
|
||||
$url = self::getTorrentUrl($siteName, $_url);
|
||||
$downloadUrl = $url;
|
||||
}
|
||||
|
||||
// 把种子URL,推送给下载器
|
||||
@@ -508,9 +502,9 @@ class AutoReseed
|
||||
$ret = self::add($k, $url, $downloadDir);
|
||||
|
||||
// 规范日志内容
|
||||
$log = 'clients_'. $k . PHP_EOL . $downloadDir . PHP_EOL . $_url . PHP_EOL.PHP_EOL;
|
||||
$log = 'clients_'. $k . PHP_EOL . $downloadDir . PHP_EOL . $downloadUrl . PHP_EOL.PHP_EOL;
|
||||
if ($ret) {
|
||||
// 成功的种子
|
||||
// 成功
|
||||
// 操作流控参数
|
||||
if (isset($configALL[$siteName]['limitRule']) && $configALL[$siteName]['limitRule']) {
|
||||
$limitRule = $configALL[$siteName]['limitRule'];
|
||||
@@ -519,12 +513,13 @@ class AutoReseed
|
||||
$configALL[$siteName]['limitRule']['time'] = time();
|
||||
}
|
||||
}
|
||||
wlog($log, $value['info_hash'], self::$cacheHash); // 添加成功的种子,以infohash为文件名,写入缓存
|
||||
// 添加成功,以infohash为文件名,写入缓存;所有客户端共用缓存,不可以重复辅种!如果需要重复辅种,请经常删除缓存!
|
||||
wlog($log, $value['info_hash'], self::$cacheHash);
|
||||
wlog($log, 'reseedSuccess');
|
||||
// 成功累加
|
||||
self::$wechatMsg['reseedSuccess']++;
|
||||
} else {
|
||||
// 失败的种子
|
||||
// 失败
|
||||
wlog($log, 'reseedError');
|
||||
// 失败累加
|
||||
self::$wechatMsg['reseedError']++;
|
||||
@@ -623,6 +618,7 @@ class AutoReseed
|
||||
}
|
||||
// 种子目录:脚本要能够读取到
|
||||
$path = self::$links[$k]['BT_backup'];
|
||||
$torrentPath = '';
|
||||
// 待删除种子
|
||||
$torrentDelete = '';
|
||||
// 获取种子原文件的实际路径
|
||||
@@ -646,7 +642,6 @@ class AutoReseed
|
||||
$torrentDelete = $info_hash;
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
if (!is_file($torrentPath)) {
|
||||
@@ -668,7 +663,6 @@ class AutoReseed
|
||||
if (isset($configALL['default']['move']['skip_check']) && $configALL['default']['move']['skip_check'] === 1) {
|
||||
$extra_options['skip_checking'] = "true"; //转移成功,跳校验
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// 添加转移任务:成功返回:true
|
||||
@@ -699,20 +693,20 @@ class AutoReseed
|
||||
* @param $k int 客户端key
|
||||
* @param $torrent array 可辅的种子
|
||||
* @param $infohash_Dir array 当前客户端hash目录对应字典
|
||||
* @param $downloadDir string 可辅种子的资源目录
|
||||
* @param $downloadDir string 辅种目录
|
||||
* @param $_url string 种子临时连接
|
||||
* @return bool
|
||||
* @return bool true 可辅种 | false 不可辅种
|
||||
*/
|
||||
private static function reseedCheck($k, $torrent, $infohash_Dir, $downloadDir, $_url)
|
||||
{
|
||||
global $configALL;
|
||||
|
||||
$info_hash = $torrent['info_hash'];
|
||||
$sid = $torrent['sid'];
|
||||
$torrent_id = $torrent['torrent_id'];
|
||||
$info_hash = $torrent['info_hash'];
|
||||
$siteName = self::$sites[$sid]['site'];
|
||||
|
||||
// 配置与passkey检测
|
||||
// passkey检测 [优先检查passkey,排除用户没有的站点]
|
||||
if (empty($configALL[$siteName]) || empty($configALL[$siteName]['passkey'])) {
|
||||
//echo '-------因当前' .$siteName. "站点未设置passkey,已跳过!!".PHP_EOL.PHP_EOL;
|
||||
self::$wechatMsg['reseedSkip']++;
|
||||
@@ -734,7 +728,7 @@ class AutoReseed
|
||||
}
|
||||
// 历史添加检测
|
||||
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']++;
|
||||
return false;
|
||||
}
|
||||
@@ -757,7 +751,7 @@ class AutoReseed
|
||||
wlog('clients_'.$k.PHP_EOL.$downloadDir.PHP_EOL."-------因当前" .$siteName. "站点触发流控,已跳过!! {$_url}".PHP_EOL.PHP_EOL, 'reseedLimit');
|
||||
self::$wechatMsg['reseedSkip']++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 操作站点流控的配置
|
||||
if (isset($configALL[$siteName]['limitRule']) && $configALL[$siteName]['limitRule']) {
|
||||
$limitRule = $configALL[$siteName]['limitRule'];
|
||||
@@ -788,8 +782,11 @@ class AutoReseed
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤已转移的种子hash
|
||||
* @param array $infohash_Dir infohash与路径对应的字典
|
||||
* @return bool true 过滤 | false 不过滤
|
||||
*/
|
||||
private static function hashFilter(&$infohash_Dir = array())
|
||||
{
|
||||
@@ -801,13 +798,16 @@ class AutoReseed
|
||||
}
|
||||
return empty($infohash_Dir) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际路径与相对路径之间互相转换
|
||||
* @param string $path
|
||||
* @return string | null string转换成功
|
||||
*/
|
||||
private static function pathReplace($path = '')
|
||||
{
|
||||
global $configALL;
|
||||
$type = $configALL['default']['move']['type'];
|
||||
$type = intval($configALL['default']['move']['type']);
|
||||
$pathArray = $configALL['default']['move']['path'];
|
||||
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
||||
switch ($type) {
|
||||
@@ -838,8 +838,10 @@ class AutoReseed
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理转移种子时所设置的过滤器、选择器
|
||||
* @param string $path
|
||||
* @return bool true 过滤 | false 不过滤
|
||||
*/
|
||||
private static function pathFilter(&$path = '')
|
||||
@@ -847,11 +849,13 @@ class AutoReseed
|
||||
global $configALL;
|
||||
$path = rtrim($path, DIRECTORY_SEPARATOR); // 提高Windows转移兼容性
|
||||
// 转移过滤器、选择器 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_selector = isset($configALL['default']['move']['path_selector']) && !empty($configALL['default']['move']['path_selector']) ? $configALL['default']['move']['path_selector'] : null;
|
||||
$path_filter = !empty($configALL['default']['move']['path_filter']) ? $configALL['default']['move']['path_filter'] : null;
|
||||
$path_selector = !empty($configALL['default']['move']['path_selector']) ? $configALL['default']['move']['path_selector'] : null;
|
||||
if (\is_null($path_filter) && \is_null($path_selector)) {
|
||||
return false;
|
||||
} elseif (\is_null($path_filter)) {
|
||||
}
|
||||
|
||||
if (\is_null($path_filter)) {
|
||||
//选择器
|
||||
if (\is_array($path_selector)) {
|
||||
foreach ($path_selector as $pathName) {
|
||||
@@ -900,19 +904,19 @@ class AutoReseed
|
||||
* 获取站点种子的URL
|
||||
* @param string $site
|
||||
* @param string $url
|
||||
* @return string
|
||||
* @return string 带host的完整种子下载连接
|
||||
*/
|
||||
private static function getTorrentUrl($site = '', $url = '')
|
||||
{
|
||||
global $configALL;
|
||||
// 兼容旧配置
|
||||
// 兼容旧配置,进行补全
|
||||
if (isset($configALL[$site]['passkey']) && $configALL[$site]['passkey']) {
|
||||
if (empty($configALL[$site]['url_replace'])) {
|
||||
$configALL[$site]['url_replace'] = array('{passkey}' => trim($configALL[$site]['passkey']));
|
||||
}
|
||||
if (empty($configALL[$site]['url_join'])) {
|
||||
$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'])) {
|
||||
$configALL[$site]['url_join'][] = $configALL[$site]['ip_type'].'=1';
|
||||
}
|
||||
@@ -932,6 +936,7 @@ class AutoReseed
|
||||
}
|
||||
/**
|
||||
* 微信模板消息拼接方法
|
||||
* @return string 发送情况,json
|
||||
*/
|
||||
private static function wechatMessage()
|
||||
{
|
||||
@@ -966,8 +971,11 @@ class AutoReseed
|
||||
$desp .= $br.'*此消息将在3天后过期*。';
|
||||
return ff($text, $desp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误的种子通知服务器
|
||||
* @param string $error
|
||||
* @return bool
|
||||
*/
|
||||
private static function sendNotify($error = '')
|
||||
{
|
||||
@@ -987,8 +995,12 @@ class AutoReseed
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置通知主体
|
||||
* @param string $siteName
|
||||
* @param int $sid
|
||||
* @param int $torrent_id
|
||||
*/
|
||||
private static function setNotify($siteName = '', $sid = 0, $torrent_id = 0)
|
||||
{
|
||||
@@ -999,8 +1011,12 @@ class AutoReseed
|
||||
'torrent_id'=> $torrent_id,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 备份功能
|
||||
* @param string $key
|
||||
* @param array $array
|
||||
* @return bool|int
|
||||
*/
|
||||
private static function backup($key = '', $array = [])
|
||||
{
|
||||
|
@@ -618,6 +618,10 @@ class transmission extends AbstractClient
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $this->url);
|
||||
if (stripos($this->url, 'https://') === 0) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 禁止验证证书
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 不检查证书
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
|
||||
|
@@ -9,36 +9,40 @@ use Curl\Curl;
|
||||
class Oauth
|
||||
{
|
||||
// 合作的站点
|
||||
public static $sites = ['ourbits','hddolby','hdhome','pthome','moecat'];
|
||||
public static $sites = ['ourbits','hddolby','hdhome','pthome','chdbits'];
|
||||
// 爱语飞飞token
|
||||
public static $token = '';
|
||||
private static $token = '';
|
||||
// 合作站点用户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作为鉴权参数
|
||||
*/
|
||||
public static function getSign()
|
||||
{
|
||||
global $configALL;
|
||||
// 爱语飞飞
|
||||
$token = isset($configALL['iyuu.cn']) && $configALL['iyuu.cn'] ? $configALL['iyuu.cn'] : '';
|
||||
if (empty($token) || strlen($token)<46) {
|
||||
echo "缺少辅种接口请求参数:爱语飞飞token \n";
|
||||
echo "请访问https://iyuu.cn 用微信扫码申请,并填入配置文件config.php内。\n\n";
|
||||
$token = empty($configALL['iyuu.cn']) ? '' : $configALL['iyuu.cn'];
|
||||
if (empty($token) || strlen($token) < 46) {
|
||||
echo "缺少辅种接口请求参数:爱语飞飞token ".PHP_EOL;
|
||||
echo "请访问https://iyuu.cn 用微信扫码申请,并填入配置文件config.php内。".PHP_EOL.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册与登录
|
||||
* 作用:在服务器端实现微信用户与合作站点用户id的关联
|
||||
* 参数:爱语飞飞token + 合作站点用户id + sha1(合作站点密钥passkey) + 合作站点标识
|
||||
* @param string $apiUrl
|
||||
* @param array $sites
|
||||
* @return bool
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function login($apiUrl = '', $sites = array())
|
||||
{
|
||||
|
@@ -393,8 +393,9 @@ function sign($timestamp)
|
||||
|
||||
/**
|
||||
* @brief 分离token中的用户uid
|
||||
* token算法:IYUU + uid + T + sha1(openid+time+盐)
|
||||
* @param string $token 用户请求token
|
||||
* @desc token算法:IYUU + uid + T + sha1(openid+time+盐)
|
||||
* @param string $token 用户请求token
|
||||
* @return bool|string
|
||||
*/
|
||||
function getUid($token)
|
||||
{
|
||||
|
@@ -2,10 +2,16 @@
|
||||
# 传入的种子备份参数
|
||||
if [ $1 ]; then
|
||||
AppName=$1
|
||||
else
|
||||
echo 'AppName not null'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $2 ]; then
|
||||
torrentDir=$2
|
||||
else
|
||||
echo 'torrentDir not null'
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 脚本当前目录
|
||||
|
@@ -7,6 +7,7 @@
|
||||
* IYUU自动辅种工具-【安装篇】Windows之git https://www.iyuu.cn/archives/367/
|
||||
* IYUU自动辅种工具-【安装篇】群晖Linux之git https://www.iyuu.cn/archives/372/
|
||||
* IYUU自动辅种工具-【安装篇】小钢炮手把手教程 https://www.iyuu.cn/archives/386/
|
||||
* IYUU自动辅种工具-【安装篇】全平台Docker安装方式 https://www.iyuu.cn/archives/401/
|
||||
* IYUU自动辅种工具--最简配置(所有平台通用教程) https://www.iyuu.cn/archives/324/
|
||||
* IYUU自动辅种工具--合作站点鉴权配置说明 https://www.iyuu.cn/archives/337/
|
||||
* IYUU自动下载种子--之RSS订阅使用教程 https://www.iyuu.cn/archives/349/
|
||||
@@ -44,7 +45,7 @@ return array(
|
||||
'host' => 'http://127.0.0.1:8083',
|
||||
'username' => 'admin',
|
||||
'password' => '',
|
||||
'root_folder'=> 1, // 0不创建根目录,1创建根目录
|
||||
'root_folder'=> 1, // 创建多文件子目录:0不创建,1创建(下载器默认1)【此处必须与下载器真实配置相同,否则添加任务不会校验!】
|
||||
'BT_backup' => '/BT_backup', // 移动做种:必须配置,Linux搜索方法:find / -name BT_backup
|
||||
'move' => 0, // 0不移动,1移动并辅种,2移动且只在当前客户端辅种
|
||||
),
|
||||
@@ -60,7 +61,7 @@ return array(
|
||||
),
|
||||
'path_filter'=> array(), //转移过滤器:不转移此路径内文件
|
||||
'path_selector' => array(), //转移选择器:只转移此路径内文件(为空时,全转移) 【优先级:过滤器 > 选择器】
|
||||
'paused' => 0, //转移成功,自动开始任务:0开始,1暂停
|
||||
'paused' => 1, //转移成功,自动开始任务:0开始,1暂停
|
||||
'skip_check' => 0, //转移成功,跳校验:0不跳、1跳校验
|
||||
'delete_torrent' => 0, //转移成功,删除当前做种:0不删除、1删除
|
||||
),
|
||||
@@ -98,7 +99,7 @@ return array(
|
||||
* 以下为各站点的独立配置(互不影响、互不冲突)
|
||||
* 自动辅种:需要配置各站的passkey(没有配置passkey的站点会自动跳过)
|
||||
*/
|
||||
// ourbits
|
||||
// 【合作站点用户鉴权】ourbits
|
||||
'ourbits' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
@@ -124,7 +125,7 @@ return array(
|
||||
),
|
||||
|
||||
),
|
||||
// hddolby
|
||||
// 【合作站点用户鉴权】hddolby
|
||||
'hddolby' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
@@ -138,7 +139,7 @@ return array(
|
||||
'sleep' => 5, // 最少休眠5秒
|
||||
),
|
||||
),
|
||||
// hdhome
|
||||
// 【合作站点用户鉴权】hdhome
|
||||
'hdhome' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
@@ -152,7 +153,7 @@ return array(
|
||||
'sleep' => 5, // 最少休眠5秒
|
||||
),
|
||||
),
|
||||
// PTHome
|
||||
// 【合作站点用户鉴权】PTHome
|
||||
'pthome' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
@@ -166,22 +167,15 @@ return array(
|
||||
'sleep' => 5, // 最少休眠5秒
|
||||
),
|
||||
),
|
||||
// MoeCat
|
||||
'moecat' => array(
|
||||
// 【合作站点用户鉴权】chdbits
|
||||
'chdbits' => 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秒
|
||||
),
|
||||
'url_join' => array(),
|
||||
),
|
||||
// m-team
|
||||
'm-team' => array(
|
||||
@@ -277,9 +271,9 @@ return array(
|
||||
// 如果需要自动辅种,必须配置
|
||||
'passkey' => '',
|
||||
// 如果需要rss订阅,必须配置
|
||||
'rss' => '',
|
||||
'url_replace' => array(),
|
||||
'url_join' => array(),
|
||||
'rss' => '',
|
||||
),
|
||||
// nanyangpt
|
||||
'nanyangpt' => array(
|
||||
@@ -366,15 +360,6 @@ return array(
|
||||
'url_replace' => array(),
|
||||
'url_join' => array(),
|
||||
),
|
||||
// chdbits
|
||||
'chdbits' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
// 如果需要自动辅种,必须配置
|
||||
'passkey' => '',
|
||||
'url_replace' => array(),
|
||||
'url_join' => array(),
|
||||
),
|
||||
// leaguehd
|
||||
'leaguehd' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
@@ -638,5 +623,21 @@ return array(
|
||||
'url_replace' => array(),
|
||||
'url_join' => array(),
|
||||
),
|
||||
// dragonhd
|
||||
'dragonhd' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
// 如果需要自动辅种,必须配置
|
||||
'passkey' => '',
|
||||
),
|
||||
// hitpt 百川
|
||||
'hitpt' => array(
|
||||
// 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项)
|
||||
'cookie' => '',
|
||||
// 如果需要自动辅种,必须配置
|
||||
'passkey' => '',
|
||||
'url_replace' => array(),
|
||||
'url_join' => array(),
|
||||
),
|
||||
// 配置结束,后面的一行不能删除,必须保留!!!
|
||||
);
|
||||
|
@@ -5,5 +5,4 @@ echo $pwddir
|
||||
cd $(dirname $0)
|
||||
git fetch --all
|
||||
git reset --hard origin/master
|
||||
git pull
|
||||
php ./iyuu.php
|
@@ -55,7 +55,7 @@ IYUU自动辅种工具(英文名:IYUUAutoReseed),是一款PHP语言编
|
||||
2. qBittorrent
|
||||
|
||||
## 支持自动辅种的站点
|
||||
学校、杜比、家园、天空、朋友、馒头、萌猫、我堡、猫站、铂金家、烧包、北洋、TCCF、南洋、TTG、映客、城市、52pt、brobits、备胎、SSD、CHD、ptmsg、leaguehd、聆音、瓷器、hdarea、eastgame(TLF)、1ptba、hdtime、hd4fans、opencd、hdbug、hdstreet、joyhd、u2、upxin(HDU)、oshen、discfan(GZT)、cnscg圣城(已删除)、北邮、CCFBits、dicmusic、天雪、葡萄、HDRoute、伊甸园hdbd、海胆haidan、HDfans。
|
||||
学校、杜比、家园、天空、朋友、馒头、萌猫、我堡、猫站、铂金家、烧包、北洋、TCCF、南洋、TTG、映客、城市、52pt、brobits、备胎、SSD、CHD、ptmsg、leaguehd、聆音、瓷器、hdarea、eastgame(TLF)、1ptba、hdtime、hd4fans、opencd、hdbug、hdstreet、joyhd、u2、upxin(HDU)、oshen、discfan(GZT)、cnscg圣城(已删除)、北邮、CCFBits、dicmusic、天雪、葡萄、HDRoute、伊甸园hdbd、海胆haidan、HDfans、龙之家、百川PT。
|
||||
|
||||
## 运行环境
|
||||
具备PHP运行环境的所有平台,例如:Linux、Windows、MacOS!
|
||||
|
Reference in New Issue
Block a user