Skip to content

Commit

Permalink
feat: 支持Deluge
Browse files Browse the repository at this point in the history
  • Loading branch information
KyokoMiki authored and vertex-app committed Jul 30, 2024
1 parent 4fd9eb2 commit 84752b5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
61 changes: 61 additions & 0 deletions app/libs/client/de.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const util = require('../util');
const fs = require('fs');

exports.login = async function (username, clientUrl, password) {
const message = {
Expand Down Expand Up @@ -84,6 +85,65 @@ exports.addTorrent = async function (clientUrl, cookie, torrentUrl, isSkipChecki
return res;
};

exports.addTorrentByTorrentFile = async function (clientUrl, cookie, filepath, isSkipChecking, uploadLimit, downloadLimit, savePath, label) {
let message = {
url: clientUrl + '/upload',
method: 'POST',
headers: {
cookie
},
formData: {
file: fs.createReadStream(filepath),

Check failure on line 96 in app/libs/client/de.js

View workflow job for this annotation

GitHub Actions / build_docker_image

Unexpected trailing comma
}
};
let res = await util.requestPromise(message);
const torrentPath = JSON.parse(res.body).files[0];
message = {
method: 'POST',
url: clientUrl + '/json',
json: true,
gzip: true,
body: {
id: 0,
method: 'web.add_torrents',
params: [
[
{
path: torrentPath,
options: {
file_priorities: [
1
],
add_paused: false,
sequential_download: false,
pre_allocate_storage: false,
move_completed: false,
max_connections: -1,
max_download_speed: downloadLimit,
max_upload_slots: -1,
max_upload_speed: uploadLimit,
prioritize_first_last_pieces: false,
seed_mode: isSkipChecking,
super_seeding: false
}
}
]
]
},
headers: {
cookie
}
};
if (savePath) {
message.body.params[0][0].options.download_location = savePath;
}
if (label) {
message.body.params[0][0].options.label = label;
}
res = await util.requestPromise(message);
return res;
};

exports.getMaindata = async function (clientUrl, cookie) {
const option = {
method: 'POST',
Expand Down Expand Up @@ -148,6 +208,7 @@ exports.getMaindata = async function (clientUrl, cookie) {
}
torrent.progress = torrent.progress / 100;
if (+torrent.progress === -1) torrent.progress = 0;
torrent.originProp = { ...res.torrents[k] };
torrent.completedTime = Math.max(Date.now() / 1000 - torrent.seedingTime, torrent.addedTime);
maindata.torrents.push(torrent);
}
Expand Down
1 change: 1 addition & 0 deletions webui/src/pages/base/Downloader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<a-select size="small" v-model:value="downloader.type" >
<a-select-option value="qBittorrent">qBittorrent</a-select-option>
<a-select-option value="Transmission">Transmission</a-select-option>
<a-select-option value="deluge">Deluge</a-select-option>
</a-select>
</a-form-item>
<a-form-item
Expand Down

0 comments on commit 84752b5

Please sign in to comment.