ledccn / iyuuplus-dev

IYUU自动辅种工具,目前能对国内大部分的PT站点自动辅种,支持下载器集群,支持多盘位,支持多下载目录,支持连接远程下载器等。
http://doc.iyuu.cn
MIT License
438 stars 24 forks source link

TR添加猫站被删除的种子会显示辅种成功 #88

Open chenmicro opened 2 months ago

chenmicro commented 2 months ago

之前有人提到过 #11 但流控只是一种情况

猫站在下载不存在的种子时返回的状态码仍然是200,使得下载器仍能下载内容,所以在以状态码判断时会出现错误。

下载猫站被删除种子时的返回内容(网页提示为Oops! this record does not exists):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>error</title>
    <style>
    body {
        height: 100%;
        background: #fafafa;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        color: #777;
        font-weight: 300;
    }
    h1 {
        font-weight: lighter;
        letter-spacing: 0.8;
        font-size: 3rem;
        margin-top: 0;
        margin-bottom: 0;
        color: #222;
    }
    .wrap {
        max-width: 1024px;
        margin: 5rem auto;
        padding: 2rem;
        background: #fff;
        text-align: center;
        border: 1px solid #efefef;
        border-radius: 0.5rem;
        position: relative;
    }
    pre {
        white-space: normal;
        margin-top: 1.5rem;
    }
    code {
        background: #fafafa;
        border: 1px solid #efefef;
        padding: 0.5rem 1rem;
        border-radius: 5px;
        display: block;
    }
    p {
        margin-top: 1.5rem;
    }
    .footer {
        margin-top: 2rem;
        border-top: 1px solid #efefef;
        padding: 1em 2em 0 2em;
        font-size: 85%;
        color: #999;
    }
    a:active,
    a:link,
    a:visited {
        color: #dd4814;
    }
</style>
</head>
<body>
    <div class="wrap">
        <h1>error</h1>
        <p>Oops! this record does not exists</p>
    </div>
</body>
</html>

在TR中,这种情况会返回无法解析种子(下载的是html):

{"arguments":{},"result":"unrecognized info"}

在成功添加时会返回种子hash(下载的是torrent):

{"arguments":{"torrent-added":{"hashString":"xxx","id":1,"name":"xxx"}},"result":"success"}

有两种可能的修改方案:

第一种是在发送到下载器前判断。看了下代码,目前辅种时会在本地下载种子再发送到下载器:

https://github.com/ledccn/iyuuplus-dev/blob/f0bda30483820a5d4fdb4c7d1f72a8899c7b324e/app/admin/services/reseed/ReseedDownloadServices.php#L130-L143

https://github.com/ledccn/iyuuplus-dev/blob/f0bda30483820a5d4fdb4c7d1f72a8899c7b324e/composer/site-manager/src/Spider/Helper.php#L35-L52

https://github.com/ledccn/iyuuplus-dev/blob/f0bda30483820a5d4fdb4c7d1f72a8899c7b324e/composer/site-manager/src/BaseDriver.php#L122-L145

那么可以在解析响应结果时判断返回的内容是否为种子,可以通过Response中的Content-Type或解析内容本身实现。

第二种是通过下载器的返回值判断,TR可以通过result属性判断是否辅种成功。但是这种方案依赖于下载器的API,稳定性和安全性不如第一种。

这种两种方案都适用于其它返回200状态码的站点。