From 2d52672693446641b78dc4ec63def6819a386f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=B1=B1=E6=9C=AA=E6=9D=A5?= Date: Tue, 16 Jul 2024 10:57:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mt=20api=20=E9=99=90=E6=B5=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/libs/push/webhook.js | 7 +++++++ app/libs/site/MTeam.js | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/libs/push/webhook.js b/app/libs/push/webhook.js index 76748f5b..bb113882 100644 --- a/app/libs/push/webhook.js +++ b/app/libs/push/webhook.js @@ -8,6 +8,13 @@ class Webhook { }; async pushWebhook (event, payload) { + if (payload.client && typeof payload.client === 'object') { + payload.client = { + id: payload.client.id, + alias: payload.client.alias, + clientUrl: payload.client.clientUrl + }; + } const option = { url: this.webhookurl, method: 'POST', diff --git a/app/libs/site/MTeam.js b/app/libs/site/MTeam.js index 1e4b004b..9f28868d 100644 --- a/app/libs/site/MTeam.js +++ b/app/libs/site/MTeam.js @@ -1,7 +1,10 @@ +const logger = require('../logger'); const util = require('../util'); const moment = require('moment'); const _api = async function (cookie, path, data, type = 'form') { + logger.debug('M-Team, Wait 2.5s.'); + await util.sleep(2500); if (type === 'form') { const { body } = await util.requestPromise({ url: `https://api.m-team.cc${path}`, @@ -62,8 +65,9 @@ class Site { // 做种体积 const seedinglist = []; let page = 1; + const pageSize = 100; while (true) { - const _seedinglist = await _api(this.cookie, '/api/member/getUserTorrentList', { userid: info.uid, type: 'SEEDING', pageNumber: page, pageSize: 100 }, 'json'); + const _seedinglist = await _api(this.cookie, '/api/member/getUserTorrentList', { userid: info.uid, type: 'SEEDING', pageNumber: page, pageSize }, 'json'); if (!_seedinglist) { throw new Error('疑似登录状态失效, 请检查 Api Key'); } @@ -71,7 +75,7 @@ class Site { seedinglist.push(seeding); } page += 1; - if (!_seedinglist.data.length) { + if (_seedinglist.data.length < pageSize) { break; } }