修复RPC添加下载任务时,ID获取错误的bug

This commit is contained in:
iyuu.cn
2020-01-13 00:32:14 +08:00
parent 2ccec4bc12
commit d7485be259
3 changed files with 36 additions and 13 deletions

View File

@ -147,32 +147,52 @@ class Rpc
case 1: //负载均衡模式
try
{
$rpcKey = self::$RPC_Key;
$type = self::$links[$rpcKey]['type'];
echo '选中:负载均衡'.$rpcKey."\n";
if( (strpos($torrent,'http://')===0) || (strpos($torrent,'https://')===0) ){
echo 'add';
$result = self::$links[$rpcKey]['rpc']->add( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子URL添加下载任务
}else{
echo 'add_metainfo';
$result = self::$links[$rpcKey]['rpc']->add_metainfo( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子文件添加下载任务
$is_url = false;
if( (strpos($torrent,'http://')===0) || (strpos($torrent,'https://')===0) || (strpos($torrent,'magnet:?xt=urn:btih:')===0) ){
$is_url = true;
}
// 负载均衡
self::rpcSelect();
$rpcKey = self::$RPC_Key;
echo '选中:负载均衡'.$rpcKey."\n";
self::rpcSelect();
// 调试
#p($result);
// 下载服务器类型 判断
$type = self::$links[$rpcKey]['type'];
switch($type){
case 'transmission':
$id = $result->arguments->torrent_added->id;
if( $is_url ){
echo 'add';
$result = self::$links[$rpcKey]['rpc']->add( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子URL添加下载任务
}else{
echo 'add_metainfo';
$result = self::$links[$rpcKey]['rpc']->add_metainfo( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子文件添加下载任务
}
$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;
}
if(!$id){
print "-----RPC添加种子任务失败 [{$result->result}] \n\n";
}else{
print "********RPC添加下载任务成功 [{$result->result}] (id=$id) \n\n";
// 新添加的任务,开始
self::$links[$rpcKey]['rpc']->start( $id );
return true;
}
break;
case 'qBittorrent':
if( $is_url ){
echo 'add';
$result = self::$links[$rpcKey]['rpc']->add( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子URL添加下载任务
}else{
echo 'add_metainfo';
$result = self::$links[$rpcKey]['rpc']->add_metainfo( $torrent, self::$links[$rpcKey]['downloadDir'], $extra_options ); // 种子文件添加下载任务
}
if ($result === 'Ok.') {
print "********RPC添加下载任务成功 [{$result}] \n\n";
return true;

View File

@ -348,7 +348,6 @@ class iyuuAutoReseed
// 发起请求
echo "正在提交辅种信息…… \n";
$res = $curl->post(self::$apiUrl . self::$endpoints['reseed'], $hashArray);
$resArray = json_decode($res->response, true);
// 写日志
if(true){
@ -441,7 +440,6 @@ class iyuuAutoReseed
$_url = 'https://' .$sites[$sitesID]['base_url']. '/' . $_url;
print "种子下载页:".$_url. "\n";
$url = download($_url, $cookie, $userAgent);
#$torrentArray = Bencode::decode($url);
break;
case 'hdcity':
if ( empty($configALL[$sites[$sitesID]['site']]['cookie']) ) {
@ -453,6 +451,7 @@ class iyuuAutoReseed
$userAgent = $configALL['default']['userAgent'];
print "种子:".$_url. "\n";
if ( isset($configALL[$sites[$sitesID]['site']]['cuhash']) ) {
// 已获取cuhash
# code...
}else {
// 获取cuhash

View File

@ -69,6 +69,10 @@
为减轻服务器压力推荐间隔3小时以上太频繁的调用接口可能被封禁
#### 问猫站的Tracker为啥是http而不是https
请退出登录在登录时勾选下面两个SSL的选项登录后复制cookie重新配置。
#### 问:如何反馈问题?
1、点击链接加入群聊【IYUU自动辅种交流】[https://jq.qq.com/?_wv=1027&k=5JOfOlM][1]