mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 07:28:39 +00:00
another method for adding torrents from the ajax ui, not functional yet
though
This commit is contained in:
parent
df680926ac
commit
846d61516b
1 changed files with 21 additions and 2 deletions
|
@ -82,7 +82,8 @@ class json_rpc:
|
||||||
"""
|
"""
|
||||||
#extra exposed methods
|
#extra exposed methods
|
||||||
json_exposed = ["update_ui","system_listMethods", "download_torrent_from_url",
|
json_exposed = ["update_ui","system_listMethods", "download_torrent_from_url",
|
||||||
"get_webui_config","set_webui_config","get_webui_templates", "get_torrent_info"]
|
"get_webui_config","set_webui_config","get_webui_templates", "get_torrent_info",
|
||||||
|
"add_torrents"]
|
||||||
cache = {}
|
cache = {}
|
||||||
|
|
||||||
def GET(self):
|
def GET(self):
|
||||||
|
@ -207,6 +208,7 @@ class json_rpc:
|
||||||
|
|
||||||
returns:
|
returns:
|
||||||
{
|
{
|
||||||
|
"filename": the torrent file
|
||||||
"name": the torrent name
|
"name": the torrent name
|
||||||
"size": the total size of the torrent
|
"size": the total size of the torrent
|
||||||
"files": the files the torrent contains
|
"files": the files the torrent contains
|
||||||
|
@ -245,14 +247,31 @@ class json_rpc:
|
||||||
"size": metadata["info"]["length"],
|
"size": metadata["info"]["length"],
|
||||||
"download": True
|
"download": True
|
||||||
})
|
})
|
||||||
log.debug(metadata)
|
|
||||||
return {
|
return {
|
||||||
|
"filename": filename,
|
||||||
"name": metadata["info"]["name"],
|
"name": metadata["info"]["name"],
|
||||||
"size": metadata["info"]["length"],
|
"size": metadata["info"]["length"],
|
||||||
"files": files,
|
"files": files,
|
||||||
"info_hash": info_hash
|
"info_hash": info_hash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def add_torrents(self, torrents):
|
||||||
|
"""
|
||||||
|
input:
|
||||||
|
torrents [{
|
||||||
|
path: the path of the torrent file,
|
||||||
|
options: the torrent options
|
||||||
|
}]
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
|
for torrent in torrents:
|
||||||
|
filename = os.path.basename(torrent['path'])
|
||||||
|
log.debug('Adding torrent %s' % filename)
|
||||||
|
fdump = open(torrent['path'], 'r').read()
|
||||||
|
aclient.add_torrent_file_binary(filename, fdump, torrent['options'])
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue