From 8593e40021932b9405a285e0c64f5946c19d75c1 Mon Sep 17 00:00:00 2001 From: KyokoMiki <161209740+KyokoMiki@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:03:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81Deluge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 新增 rss 规格克隆 --- app/libs/client/de.js | 61 +++++++++++++++++++++++++++++ webui/src/pages/base/Downloader.vue | 3 +- webui/src/pages/rule/Rss.vue | 5 +++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/app/libs/client/de.js b/app/libs/client/de.js index e351fe9a..6a5b9f2e 100644 --- a/app/libs/client/de.js +++ b/app/libs/client/de.js @@ -1,4 +1,5 @@ const util = require('../util'); +const fs = require('fs'); exports.login = async function (username, clientUrl, password) { const message = { @@ -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) + } + }; + 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', @@ -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); } diff --git a/webui/src/pages/base/Downloader.vue b/webui/src/pages/base/Downloader.vue index 65dec215..ea931101 100644 --- a/webui/src/pages/base/Downloader.vue +++ b/webui/src/pages/base/Downloader.vue @@ -90,11 +90,12 @@ qBittorrent Transmission + Deluge