Skip to content

Commit

Permalink
fix: mt api 限流问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vertex-app committed Jul 16, 2024
1 parent eb0b2ed commit 2d52672
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/libs/push/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 6 additions & 2 deletions app/libs/site/MTeam.js
Original file line number Diff line number Diff line change
@@ -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}`,
Expand Down Expand Up @@ -62,16 +65,17 @@ 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');
}
for (const seeding of _seedinglist.data) {
seedinglist.push(seeding);
}
page += 1;
if (!_seedinglist.data.length) {
if (_seedinglist.data.length < pageSize) {
break;
}
}
Expand Down

0 comments on commit 2d52672

Please sign in to comment.