deluge.ui.web.json_api

class deluge.ui.web.json_api.WebApi

The component that implements all the methods required for managing the web interface. The complete web json interface also exposes all the methods available from the core RPC.

add_host(host, port, username='', password='')

Adds a host to the list.

Parameters:
  • host (string) – the hostname
  • port (int) – the port
  • username (string) – the username to login as
  • password (string) – the password to login with
add_torrents(torrents)

Add torrents by file

Parameter:torrents (list) – A list of dictionaries containing the torrent path and torrent options to add with.

Usage

>>> json_api.web.add_torrents([{
        "path": "/tmp/deluge-web/some-torrent-file.torrent",
        "options": {"download_path": "/home/deluge/"}
    }])
connect(host_id)

Connect the client to a daemon

Parameter:host_id (string) – the id of the daemon in the host list
Returns:the methods the daemon supports
Return type:list
connected()

The current connection state.

Returns:True if the client is connected
Return type:booleon
disconnect()
Disconnect the web interface from the connected daemon.
download_torrent_from_url(url, cookie=None)

Download a torrent file from a url to a temporary directory.

Parameter:url (string) – the url of the torrent
Returns:the temporary file name of the torrent file
Return type:string
get_host(host_id)

Return the information about a host

Parameter:host_id (string) – the id of the host
Returns:the host information
Return type:list
get_host_status(host_id)

Returns the current status for the specified host.

Parameter:host_id (string) – the hash id of the host
get_hosts()
Return the hosts in the hostlist.
get_torrent_files(torrent_id)

Gets the files for a torrent in tree format

Parameter:torrent_id (string) – the id of the torrent to retrieve.
Returns:The torrents files in a tree
Return type:dictionary
get_torrent_info(filename)

Return information about a torrent on the filesystem.

Parameter:filename (string) – the path to the torrent
Returns:information about the torrent:
{
    "filename": the torrent file,
    "name": the torrent name,
    "size": the total size of the torrent,
    "files": the files the torrent contains,
    "info_hash" the torrents info_hash
}
Return type:dictionary
remove_host(connection_id)

Removes a host for the list

Parameter:host_id (string) – the hash id of the host
stop_daemon(host_id)

Stops a running daemon.

Parameter:host_id (string) – the hash id of the host
update_ui(keys, filter_dict)

Gather the information required for updating the web interface.

Parameters:
  • keys (list) – the information about the torrents to gather
  • filter_dict (dictionary) – the filters to apply when selecting torrents.
Returns:

The torrent and ui information.

Return type:

dictionary

deluge.ui.web.json_api.export(auth_level=None)

Decorator function to register an object’s method as a RPC. The object will need to be registered with a :class:JSON to be effective.

Parameters:
  • func (function) – the function to export
  • auth_level (int) – the auth level required to call this method

Previous topic

deluge.ui.web.gen_gettext

Next topic

deluge.ui.web.pluginmanager

This Page