deluge-client


Namedeluge-client JSON
Version 1.10.2 PyPI version JSON
download
home_pagehttps://github.com/JohnDoee/deluge-client
SummarySimple Deluge Client
upload_time2024-02-17 15:15:40
maintainerJohn Doee
docs_urlNone
authorAnders Jensen
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Deluge Client
=============
.. image:: 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):

.. code-block:: bash

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

From PyPi (stable):

.. code-block:: bash

    pip install deluge-client

Usage
-----

.. code-block:: python

    >>> 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.

.. code-block:: python

    >>> 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.

.. code-block:: python

    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

.. code-block:: python

    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 </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 :code:`core.` - Check out `this search <https://github.com/deluge-torrent/deluge/search?l=Python&q=%22%40export%22>`_ for all commands
and `core.py <https://github.com/deluge-torrent/deluge/blob/develop/deluge/core/core.py>`_ for core commands.

The exported commands are decorated with :code:`@export`.

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

.. code-block:: python

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

License
-------

MIT, see LICENSE

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JohnDoee/deluge-client",
    "name": "deluge-client",
    "maintainer": "John Doee",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Anders Jensen",
    "author_email": "andersandjensen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f1/53/d6672ad7b44190d578ce7520822af34e7119760df9934cad4d730b0592a2/deluge-client-1.10.2.tar.gz",
    "platform": null,
    "description": "Deluge Client\n=============\n.. image:: https://github.com/JohnDoee/deluge-client/actions/workflows/main.yml/badge.svg?branch=develop\n\nA lightweight pure-python rpc client for deluge.\nNote, does not support events and any additional replies from deluge will mess up the datastream.\n\nRequirements\n------------\n\n- Deluge 1.3.x, 2.0, 2.1\n- Python 3.8, 3.9, 3.10, 3.11, 3.12\n\nInstall\n-------\n\nFrom GitHub (develop):\n\n.. code-block:: bash\n\n    pip install git+https://github.com/JohnDoee/deluge-client.git#develop\n\nFrom PyPi (stable):\n\n.. code-block:: bash\n\n    pip install deluge-client\n\nUsage\n-----\n\n.. code-block:: python\n\n    >>> from deluge_client import DelugeRPCClient\n\n    >>> client = DelugeRPCClient('127.0.0.1', 12345, 'username', 'password')\n    >>> client.connect()\n    >>> client.connected\n    True\n    >>> client.call('core.get_torrents_status', {}, ['name'])\n    {'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}\n    >>> client.core.get_torrents_status({}, ['name'])\n    {'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}\n\nIt is also usable as a context manager.\n\n.. code-block:: python\n\n    >>> from deluge_client import DelugeRPCClient\n\n    >>> with DelugeRPCClient('127.0.0.1', 12345, 'username', 'password') as client:\n    ...     client.call('core.get_torrents_status', {}, ['name'])\n    {'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}\n\n\nIdiom to use for automatic reconnect where the daemon might be offline at call time.\n\n.. code-block:: python\n\n    import time\n\n    from deluge_client import DelugeRPCClient, FailedToReconnectException\n\n    def call_retry(client, method, *args, **kwargs):\n        # We will only try the command 10 times\n        for _ in range(10):\n            try:\n                return client.call(method, *args, **kwargs)\n            except FailedToReconnectException:\n                # 5 second delay between calls\n                time.sleep(5)\n\nIdiom usage\n\n.. code-block:: python\n\n    client = DelugeRPCClient('127.0.0.1', 58846, 'username', 'password', automatic_reconnect=True)\n    # The client has to be online when you start the process,\n    # otherwise you must handle that yourself.\n    client.connect()\n    call_retry(client, 'core.get_torrents_status', {}, ['name'])\n    # or if you have local Deluge instance, you can use the local client\n    # LocalDelugeRPCClient accepts the same parameters, but username and password can be omitted\n    from deluge_client import LocalDelugeRPCClient\n    localclient = LocalDelugeRPCClient()\n    localclient.connect()\n\nExamples\n--------\n\nThere's an example of how you might use this client in the `examples </examples>`_ directory\n\n\nList of Deluge RPC commands\n---------------------------\n\nSadly, this part isn't well documented. Your best bet is to check out the source code and try to figure\nout what you need. The commands are namespaced so the commands you mostly need, core commands, are prefixed\nwith a :code:`core.` - Check out `this search <https://github.com/deluge-torrent/deluge/search?l=Python&q=%22%40export%22>`_ for all commands\nand `core.py <https://github.com/deluge-torrent/deluge/blob/develop/deluge/core/core.py>`_ for core commands.\n\nThe exported commands are decorated with :code:`@export`.\n\nYou can also get a list of exported commands by calling the :code:`daemon.get_method_list` method:\n\n.. code-block:: python\n\n    client.call('daemon.get_method_list')\n    # or\n    client.daemon.get_method_list()\n\nLicense\n-------\n\nMIT, see LICENSE\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple Deluge Client",
    "version": "1.10.2",
    "project_urls": {
        "Homepage": "https://github.com/JohnDoee/deluge-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a37167fc27ae423905d3b38824a403f32f12c6b8c5679104e47838dfb294afd",
                "md5": "14c64afe5b19af236d1f5f1eb7578051",
                "sha256": "ea052663c0ed3a2247517d316c3784d70c83279dd9e088623fd06b164768f4f1"
            },
            "downloads": -1,
            "filename": "deluge_client-1.10.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "14c64afe5b19af236d1f5f1eb7578051",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12355,
            "upload_time": "2024-02-17T15:15:38",
            "upload_time_iso_8601": "2024-02-17T15:15:38.561093Z",
            "url": "https://files.pythonhosted.org/packages/0a/37/167fc27ae423905d3b38824a403f32f12c6b8c5679104e47838dfb294afd/deluge_client-1.10.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f153d6672ad7b44190d578ce7520822af34e7119760df9934cad4d730b0592a2",
                "md5": "59cb22e644c95342d2d0c226a318d1a4",
                "sha256": "3881aee3c4e0ca9dd8a56b710047b837e1d087a83e421636a074771f92a9f1b5"
            },
            "downloads": -1,
            "filename": "deluge-client-1.10.2.tar.gz",
            "has_sig": false,
            "md5_digest": "59cb22e644c95342d2d0c226a318d1a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12601,
            "upload_time": "2024-02-17T15:15:40",
            "upload_time_iso_8601": "2024-02-17T15:15:40.249696Z",
            "url": "https://files.pythonhosted.org/packages/f1/53/d6672ad7b44190d578ce7520822af34e7119760df9934cad4d730b0592a2/deluge-client-1.10.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-17 15:15:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JohnDoee",
    "github_project": "deluge-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "deluge-client"
}
        
Elapsed time: 0.31440s