Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/common/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ class Client {
}
};

async addTorrent (torrentUrl, hash, isSkipChecking = false, uploadLimit = 0, downloadLimit = 0, savePath, category, autoTMM, paused) {
async addTorrent (link,torrentUrl, hash, isSkipChecking = false, uploadLimit = 0, downloadLimit = 0, savePath, category, autoTMM, paused) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link, torrentUrl

格式注意下,其它地方也是,过不了 eslint

if (!this.status) {
throw new Error('客户端' + this.alias + '当前状态为不可用');
}
const { statusCode } = await this.client.addTorrent(this.clientUrl, this.cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM, this.firstLastPiecePrio, paused);
const { statusCode } = await this.client.addTorrent(link,this.clientUrl, this.cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM, this.firstLastPiecePrio, paused);
if (statusCode !== 200) {
this.login();
throw new Error('状态码: ' + statusCode);
Expand Down Expand Up @@ -370,6 +370,7 @@ class Client {

async deleteTorrent (torrent, rule) {
let isDeleteFiles = true;
let isSendNTF = true;
try {
for (const _torrent of this.maindata.torrents) {
if (_torrent.name === torrent.name && _torrent.size === torrent.size && _torrent.hash !== torrent.hash && _torrent.savePath === torrent.savePath) {
Expand All @@ -388,8 +389,13 @@ class Client {
} else {
await this.client.deleteTorrent(this.clientUrl, this.cookie, torrent.hash, isDeleteFiles);
}
logger.info('下载器', this.alias, '删除种子成功:', torrent.name, rule.alias);
await this.ntf.deleteTorrent(this._client, torrent, rule, isDeleteFiles);
logger.info('下载器', this.alias, '删除种子成功:', torrent.name, rule.alias);
if (rule.doNotSendNotify){
isSendNTF = false;
}
if (isSendNTF){
await this.ntf.deleteTorrent(this._client, torrent, rule, isDeleteFiles);
}
} catch (error) {
logger.error('下载器', this.alias, '删除种子失败:', torrent.name, '\n', error);
await this.ntf.deleteTorrentError(this._client, torrent, rule);
Expand Down
4 changes: 2 additions & 2 deletions app/common/Rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Rss {
if (_torrent.name === bencodeInfo.name && _torrent.hash !== bencodeInfo.hash) {
try {
this.addCount += 1;
await client.addTorrent(torrent.url, torrent.hash, true, this.uploadLimit, this.downloadLimit, _torrent.savePath, this.category);
await client.addTorrent(torrent.link,torrent.url, torrent.hash, true, this.uploadLimit, this.downloadLimit, _torrent.savePath, this.category);
await util.runRecord('INSERT INTO torrents (hash, name, size, rss_id, category, link, record_time, add_time, record_type, record_note) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[torrent.hash, torrent.name, torrent.size, this.id, this.category, torrent.link, moment().unix(), moment().unix(), 1, '辅种']);
await this.ntf.addTorrent(this._rss, client, torrent);
Expand Down Expand Up @@ -347,7 +347,7 @@ class Rss {
const { filepath, hash } = await this._downloadTorrent(torrent.url, torrent.hash);
await client.addTorrentByTorrentFile(filepath, hash, false, this.uploadLimit, this.downloadLimit, savePath, category, this.autoTMM, this.paused);
} else {
await client.addTorrent(torrent.url, torrent.hash, false, this.uploadLimit, this.downloadLimit, savePath, category, this.autoTMM, this.paused);
await client.addTorrent(torrent.link,torrent.url, torrent.hash, false, this.uploadLimit, this.downloadLimit, savePath, category, this.autoTMM, this.paused);
}
try {
await this.ntf.addTorrent(this._rss, client, torrent);
Expand Down
2 changes: 1 addition & 1 deletion app/libs/client/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.login = async function (username, clientUrl, password) {
return res.headers['set-cookie'][0].substring(0, res.headers['set-cookie'][0].indexOf(';'));
};

exports.addTorrent = async function (clientUrl, cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, label) {
exports.addTorrent = async function (link,clientUrl, cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, label) {
let message = {
method: 'POST',
url: clientUrl + '/json',
Expand Down
5 changes: 4 additions & 1 deletion app/libs/client/qb.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.login = async function (username, clientUrl, password) {
}
};

exports.addTorrent = async function (clientUrl, cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM, firstLastPiecePrio, paused) {
exports.addTorrent = async function (link,clientUrl, cookie, torrentUrl, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM, firstLastPiecePrio, paused) {
const message = {
url: clientUrl + '/api/v2/torrents/add',
method: 'POST',
Expand All @@ -49,6 +49,9 @@ exports.addTorrent = async function (clientUrl, cookie, torrentUrl, isSkipChecki
if (autoTMM) {
message.formData.autoTMM = '' + autoTMM;
}
if (paused) {
message.formData.tags = link;
}
const res = await util.requestPromise(message);
logger.debug(clientUrl, '添加种子', torrentUrl, '\n返回信息', { body: res.body, statusCode: res.statusCode });
return res;
Expand Down
2 changes: 1 addition & 1 deletion app/libs/client/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports.login = async function (username, clientUrl, password) {
};
};

exports.addTorrentByTorrentFile = async function (clientUrl, cookie, filepath, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM) {
exports.addTorrentByTorrentFile = async function (link,clientUrl, cookie, filepath, isSkipChecking, uploadLimit, downloadLimit, savePath, category, autoTMM) {
const message = {
method: 'POST',
url: clientUrl + '/transmission/rpc',
Expand Down