Skip to main content

Deluge Client

https://github.com/JohnDoee/deluge-client/actions/workflows/main.yml/badge.svg?branch=develop

A lightweight pure-python rpc client for deluge. Note, does not support events and any additional replies from deluge will mess up the datastream.

Requirements

  • Deluge 1.3.x, 2.0, 2.1

  • Python 3.8, 3.9, 3.10, 3.11, 3.12

Install

From GitHub (develop):

pip install git+https://github.com/JohnDoee/deluge-client.git#develop

From PyPi (stable):

pip install deluge-client

Usage

>>> from deluge_client import DelugeRPCClient

>>> client = DelugeRPCClient('127.0.0.1', 12345, 'username', 'password')
>>> client.connect()
>>> client.connected
True
>>> client.call('core.get_torrents_status', {}, ['name'])
{'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}
>>> client.core.get_torrents_status({}, ['name'])
{'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}

It is also usable as a context manager.

>>> from deluge_client import DelugeRPCClient

>>> with DelugeRPCClient('127.0.0.1', 12345, 'username', 'password') as client:
...     client.call('core.get_torrents_status', {}, ['name'])
{'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}

Idiom to use for automatic reconnect where the daemon might be offline at call time.

import time

from deluge_client import DelugeRPCClient, FailedToReconnectException

def call_retry(client, method, *args, **kwargs):
    # We will only try the command 10 times
    for _ in range(10):
        try:
            return client.call(method, *args, **kwargs)
        except FailedToReconnectException:
            # 5 second delay between calls
            time.sleep(5)

Idiom usage

client = DelugeRPCClient('127.0.0.1', 58846, 'username', 'password', automatic_reconnect=True)
# The client has to be online when you start the process,
# otherwise you must handle that yourself.
client.connect()
call_retry(client, 'core.get_torrents_status', {}, ['name'])
# or if you have local Deluge instance, you can use the local client
# LocalDelugeRPCClient accepts the same parameters, but username and password can be omitted
from deluge_client import LocalDelugeRPCClient
localclient = LocalDelugeRPCClient()
localclient.connect()

Examples

There’s an example of how you might use this client in the examples directory

List of Deluge RPC commands

Sadly, this part isn’t well documented. Your best bet is to check out the source code and try to figure out what you need. The commands are namespaced so the commands you mostly need, core commands, are prefixed with a core. - Check out this search for all commands and core.py for core commands.

The exported commands are decorated with @export.

You can also get a list of exported commands by calling the daemon.get_method_list method:

client.call('daemon.get_method_list')
# or
client.daemon.get_method_list()

License

MIT, see LICENSE

Metadata

Release files for deluge-client 1.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deluge-client 1.10.2
File Size Uploaded
deluge-client-1.10.2.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deluge-client 1.10.2
File Interpreter ABI Platform
deluge_client-1.10.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / deluge-client-1.10.2.tar.gz

Download URL deluge-client-1.10.2.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3881aee3c4e0ca9dd8a56b710047b837e1d087a83e421636a074771f92a9f1b5
BLAKE2b-256 checksum
How to use checksums
f153d6672ad7b44190d578ce7520822af34e7119760df9934cad4d730b0592a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / deluge_client-1.10.2-py3-none-any.whl

Download URL deluge_client-1.10.2-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea052663c0ed3a2247517d316c3784d70c83279dd9e088623fd06b164768f4f1
BLAKE2b-256 checksum
How to use checksums
0a37167fc27ae423905d3b38824a403f32f12c6b8c5679104e47838dfb294afd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

1.10.2 This release

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.5

1 release file

1.0.4

2 release files

1.0.3

1 release file

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page