pt-plugins / PT-Plugin-Plus

PT 助手 Plus,为 Microsoft Edge、Google Chrome、Firefox 浏览器插件(Web Extensions),主要用于辅助下载 PT 站的种子。
MIT License
6.62k stars 838 forks source link

Mt 获取信息一直转圈圈 #1936

Closed ted423 closed 1 month ago

ted423 commented 1 month ago

请确认你已经做过并了解如下步骤,在 [] 中填入 x 选中

测试2693开始版本应该都有问题

ted423 commented 1 month ago

Mit | Snow on the beach, [2024/7/3 16:44] 你的保种太多就容易不成功

游戏真有意思, [2024/7/3 16:44] 所以是保种太多丢了一堆请求过去?

Mit | Snow on the beach, [2024/7/3 16:44] 一次请求不完 就第二次第三次

ted423 commented 1 month ago

image

jiang925 commented 1 month ago

我用的zip安装模式。找到一个临时补救方法。

resource/sites/xp.m-team.cc/getUserSeedingTorrents.js文件里的load()改成下面的样子。隔几秒重试一次。只是个临时的补救。如果请求一直被屏蔽的话,这个方法会导致无限重试。

    /**
     * 加载当前页内容
     */
    load() {
      let url = this.dataURL;
      let postData = this.options.rule.requestData;
      postData.pageNumber = this.pageInfo.current + 1;

      function makeRequest() {
        $.ajax({
          url,
          method: "POST",
          dataType: "JSON",
          data: JSON.stringify(postData),
          contentType: "application/json",
          headers: this.options.rule.headers
        })
          .done(result => {
            try {
              this.rawData = result;
              if (this.rawData.data.data.length > 0) {
                this.parse();
              } else {
                this.done();
              }
            } catch (error) {
              console.error('Error processing mt load result:', error);
              setTimeout(() => {
                makeRequest.call(this);
              }, 8000);
            }
          })
          .fail(() => {
            this.done();
          });
      }

      makeRequest.call(this);
    }

下面这个加了次数限制。但我没有深入测试。。

function makeRequest(retryCount = 0) {
  $.ajax({
    url,
    method: "POST",
    dataType: "JSON",
    data: JSON.stringify(postData),
    contentType: "application/json",
    headers: this.options.rule.headers
  })
    .done(result => {
      try {
        this.rawData = result;
        if (this.rawData.data.data.length > 0) {
          this.parse();
        } else {
          this.done();
        }
      } catch (error) {
        console.error('Error processing result:', error);
        if (retryCount < 2) {
          setTimeout(() => {
            makeRequest.call(this, retryCount + 1);
          }, 8000);
        } else {
          this.done();
        }
      }
    })
    .fail(() => {
      this.done();
    });
}

// Call the function for the first time
makeRequest.call(this);
ted423 commented 1 month ago

@jiang925 无限千万不行,到时候指不定号就没了

jiang925 commented 1 month ago

@jiang925 无限千万不行,到时候指不定号就没了

明白。只能临时用一下。我打算手动刷新的时候,如果看一直重试,刷新一下页面就可以终止重试。不过提醒了我,如果半夜自动刷新的时候无限重试的话就可能会跪。

又多测试了一下后面带retry的。在try里面强制生成了一个错误。测试可以retry两次后停止。

trim21 commented 1 month ago

建议你每天去馒头群问问什么时候有统计做种情况的api