Opened 11 years ago

Last modified 21 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.1.1
Component: Web UI Version: master
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 (8)

comment:1 Changed 11 years ago by RushFuture

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

comment:2 Changed 11 years ago by Cas

  • Milestone changed from Future to 1.4.0

comment:3 Changed 7 years ago by Cas

  • Milestone changed from 2.0.x to 2.x

Milestone renamed

comment:4 Changed 7 years ago by Cas

  • Milestone changed from 2.x to 2.0

comment:5 Changed 6 years ago by Cas

  • Milestone changed from 2.0 to 2.0.0

Milestone renamed

comment:6 Changed 5 years ago by Cas

  • Milestone changed from 2.0.0 to 2.1.x

Ticket retargeted after milestone closed

comment:7 Changed 2 years ago by Cas

  • Milestone changed from 2.1.x to 2.1.0

Milestone renamed

comment:8 Changed 21 months ago by Cas

  • Milestone changed from 2.1.0 to 2.1.1

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.