Opened 5 years ago

Last modified 7 months ago

#2320 new patch

Directly send torrent-file content to Web UI JSON-RPC add_torrents method

Reported by: RushFuture Owned by: damoxc
Priority: minor Milestone: 2.0
Component: Web UI Version: master (git)
Keywords: Cc:

Description

I'm starting to develop extension for Chromium https://github.com/RushOnline/chrome-sendlink, which will allow one-click upload torrent file to Deluge server. This is need because many trackers doesn't allow direct download torrent files. It will be awesome if WebUI JSON-RPC add_torrents method accept one more pair (named "data" in my patch) for "torrent" dictionary.

My experiments are now focused on http://rutracker.org/, but future plans include support other trackers denied direct torrent files download.

Later I'll communicate with deluge-chrome-extension author, may be he is interested to integrate the same functionality to his extension.

diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py
index 4febab1..e90c6ee 100644
--- a/deluge/ui/web/json_api.py
+++ b/deluge/ui/web/json_api.py
@@ -750,7 +750,8 @@ def add_torrents(self, torrents):
         Add torrents by file
 
         :param torrents: A list of dictionaries containing the torrent \
-        path and torrent options to add with.
+        path, torrent data and torrent options to add with. Torrent data \
+        is optional and must be encoded with base64.
         :type torrents: list
 
         **Usage**
@@ -768,7 +769,7 @@ def add_torrents(self, torrents):
                 client.core.add_torrent_magnet(torrent["path"], torrent["options"])
             else:
                 filename = os.path.basename(torrent["path"])
-                fdump = base64.encodestring(open(torrent["path"], "rb").read())
+                fdump = torrent.pop("data", None) || base64.encodestring(open(torrent["path"], "rb").read())
                 log.info("Adding torrent from file `%s` with options `%r`",
                          filename, torrent["options"])
                 client.core.add_torrent_file(filename, fdump, torrent["options"])

Change History (4)

comment:1 Changed 5 years ago by RushFuture

"
" must be replaced with "or", I'm sorry.

comment:2 Changed 5 years ago by Cas

  • Milestone changed from Future to 1.4.0

comment:3 Changed 7 months ago by Cas

  • Milestone changed from 2.0.x to 2.x

Milestone renamed

comment:4 Changed 7 months ago by Cas

  • Milestone changed from 2.x to 2.0
Note: See TracTickets for help on using tickets.