Compare commits

..

5 Commits

Author SHA1 Message Date
iyuu.cn
01a9b71e9f 为避免多php版本带来困扰,cmd批处理内php采用环境变量调用。 2020-03-25 12:31:30 +08:00
iyuu.cn
f89b5f7325 v1.7.0 2020-03-23 13:19:45 +08:00
iyuu.cn
5880f563e8 增加通用备份脚本,可以添加进计划任务。 2020-03-23 13:05:03 +08:00
iyuu.cn
61eb8f69c9 简化辅种输出。 2020-03-22 11:29:47 +08:00
iyuu.cn
b4ca455a75 优化输出提示,未填写passkey的站点自动跳过,不提示。 2020-03-22 11:24:52 +08:00
6 changed files with 48 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
@echo off @echo off
chcp 65001 chcp 65001
%cd%\php\php %cd%\iyuu.php php %cd%\iyuu.php
pause pause

View File

@@ -3,5 +3,5 @@ chcp 65001
git fetch --all git fetch --all
git reset --hard origin/master git reset --hard origin/master
git pull git pull
%cd%\php\php.exe %cd%\iyuu.php php %cd%\iyuu.php
pause pause

View File

@@ -1,4 +1,4 @@
@echo off @echo off
chcp 65001 chcp 65001
D:\IYUUAutoReseed\php\php.exe D:\IYUUAutoReseed\iyuu.php php D:\IYUUAutoReseed\iyuu.php
exit exit

View File

@@ -13,19 +13,19 @@ use IYUU\Library\Table;
class AutoReseed class AutoReseed
{ {
// 版本号 // 版本号
const VER = '1.6.7'; const VER = '1.7.0';
// 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;
@@ -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'])) {
@@ -615,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'];
@@ -627,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);
/** /**
@@ -789,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;
} }
} }

24
backup.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
# 传入的种子备份参数
if [ $1 ]; then
AppName=$1
fi
if [ $2 ]; then
torrentDir=$2
fi
# 脚本当前目录
pwddir=$(cd $(dirname $0); pwd)
# 当前日期
DATE=$(date +%Y%m%d)
# 备份在当前目录
backupdir=$pwddir"/"$AppName$DATE
echo "种子备份目录:"$backupdir
mkdir $backupdir -p
# 种子目录
torrentDir=$torrentDir"/*"
# 备份
cp -rf $torrentDir $backupdir
# 成功提示
echo "ok";

View File

@@ -1,5 +0,0 @@
@echo off
chcp 65001
git fetch --all
git reset --hard origin/master
git pull