Skip to main content

Simple Deluge Client

Project description

https://ci.appveyor.com/api/projects/status/8s3g4uucg2xcay6v/branch/develop?svg=true

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 beta

  • Python 2.7, 3.5, 3.6, 3.7

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()

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deluge-client-1.9.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deluge_client-1.9.0-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file deluge-client-1.9.0.tar.gz.

File metadata

  • Download URL: deluge-client-1.9.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.5

File hashes

Hashes for deluge-client-1.9.0.tar.gz
Algorithm Hash digest
SHA256 0d2f12108a147d44590c8df63997fcb32f8b2fbc18f8cbb221f0136e2e372b85
MD5 e89bd88bcf1e7c5e97e4cd7a695c0ccc
BLAKE2b-256 ef52f68966132aebea6703caa0b9d12e40581f09725ddf07c97ebb2c4664bb84

See more details on using hashes here.

File details

Details for the file deluge_client-1.9.0-py2.py3-none-any.whl.

File metadata

  • Download URL: deluge_client-1.9.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.5

File hashes

Hashes for deluge_client-1.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3ee0db7b1da4f55c3210886ca0647d18eaa2f739b7215735424304412484ac06
MD5 3af5707a4d6290056c13c91ed30ef678
BLAKE2b-256 460e1e1e4a63be74367655d74b2ca17b47c66544d8608bb7412ed2eee5092a4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page