9 Star 85 Fork 18

大卫/IYUUPlus

 / 详情

IYUU QB 4.4.x版本 转种 到TR 丢失 trackers 信息修复

待办的
创建于  
2022-09-24 17:14

本萌新简单粗暴的基于QB4.4.5版本做了添加trackers信息填入,测试可用,具体更全的希望大佬能进行修改

MoveTorrent.php 文件
在 遍历当前客户端种子 行为中 增加了读取QB种子对应的 .fastresume 文件中存在trackers信息
通过获取文件内容去获取相关信息
需要引入Bencode相关内容

use Rhilip\Bencode\Bencode;
use Rhilip\Bencode\ParseException;
                // 种子目录:脚本要能够读取到
                $path = self::$links[$k]['BT_backup'];
                $torrentPath = '';
                $resumePath = '';
                // 待删除种子
                $torrentDelete = '';
                // 获取种子文件的实际路径
                switch ($v['type']) {
                    case 'transmission':
                        // 优先使用API提供的种子路径
                        $torrentPath = $move[$info_hash]['torrentFile'];
                        $torrentDelete = $move[$info_hash]['id'];
                        // API提供的种子路径不存在时,使用配置内指定的BT_backup路径
                        if (!is_file($torrentPath)) {
                            $torrentPath = str_replace("\\", "/", $torrentPath);
                            $torrentPath = $path . strrchr($torrentPath, '/');
                        }
                        echo 'TR存在种子:' . $torrentPath . PHP_EOL;
                        break;
                    case 'qBittorrent':
                        if (empty($path)) {
                            echo $help_msg;
                            die("clients_" . $k . " IYUUPlus内下载器未设置种子目录,无法完成转移!");
                        }
                        $torrentPath = $path . DS . $info_hash . '.torrent';
                        $resumePath = $path . DS . $info_hash . '.fastresume';
                        $torrentDelete = $info_hash;
                        echo 'QB存在种子:' . $torrentPath . PHP_EOL;
                        break;
                    default:
                        break;
                }
                if (!is_file($torrentPath)) {
                    echo $help_msg;
                    die("clients_" . $k . " 的种子文件{$torrentPath}不存在,无法完成转移!");
                }
                echo '存在种子:' . $torrentPath . PHP_EOL;
                $torrent = file_get_contents($torrentPath);
                // 正式开始转移
                echo "种子已推送给下载器,正在转移做种..." . PHP_EOL;

                // 目标下载器类型
                $clientKey = self::$conf['to_clients']['uuid'];
                $type = self::$links[$clientKey]['type'];
                $extra_options = array();
                // 转移后,是否开始?
                $extra_options['paused'] = isset(self::$conf['paused']) && self::$conf['paused'] ? true : false;
                if ($type == 'qBittorrent') {
                    if (isset(self::$conf['skip_check']) && self::$conf['skip_check']) {
                        $extra_options['skip_checking'] = "true";    //转移成功,跳校验
                    }
                }
                $res_resume = "";
                echo "种子$type:$resumePath" . PHP_EOL;
                if ($type == 'transmission' && !empty($resumePath)) {
                    // qb 4.4.x 版本 转移种子从 fastresume 中获取 trackers 信息
                    // 初步筛选出 qb 的 trackers 信息 并提取相关内容 目前默认取出第一条的 trackers 信息
                    $res_resume_str = file_get_contents($resumePath);
                    $res_resume_str = strstr($res_resume_str, 'trackers');
                    $keyLen = strpos($res_resume_str, 'ee');
                    $res_resume_str = substr($res_resume_str, 8, ($keyLen - 6));
                    echo "种子$res_resume_str" . PHP_EOL;
                    $res_resume = Bencode::decode($res_resume_str);
                    if (!empty($res_resume)) {
                        $extra_options['announce'] = $res_resume[0];
                    }
                }
                echo json_encode($extra_options) . PHP_EOL;

在 AutoReseed.php 文件中
add 方法中 tr 类别中
在注释 添加下载任务成功下面增加了通过调用TR 自带的 增加 trackers 方法将信息补充了进去

if (isset($extra_options['announce']) && !empty($extra_options['announce'])) {
    // 添加 qb 下载器的 trackers 信息
    $res = static::getRpc($clientKey)->set([$id], ['trackerAdd' => $extra_options['announce']]);
    if (isset($res['result']) && $res['result'] == 'success') {
        print "********TR-TRACKERS添加成功 [" . $result['result'] . "] (id=" . $id . ")" . PHP_EOL .     PHP_EOL;
    } else {
        print "********TR-TRACKERS添加失败 [" . $result['result'] . "] (id=" . $id . ")" . PHP_EOL . PHP_EOL;
    }
}

评论 (0)

淡定随缘 创建了任务

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
PHP
1
https://gitee.com/ledc/iyuuplus.git
git@gitee.com:ledc/iyuuplus.git
ledc
iyuuplus
IYUUPlus

搜索帮助

Cb406eda 1850385 E526c682 1850385