JohnDoee / deluge-client

A very lightweight pure-python Deluge RPC Client
MIT License
87 stars 14 forks source link

Explanations about deluge.call #31

Closed luizoti closed 4 years ago

luizoti commented 4 years ago

Hi, How do I use the 'deluge.call' method to extract additional information and convert a dictionary to whom it can be used as "normal"?

deluge.call('core.get_torrents_status', {'id': '827544c22ccfd904807ebb0d430660785c5c6dd9'}, ['hash', 'move_on_completed_path', 'move_on_completed', 'progress', 'download_location', 'state'])

Currently I can only generate this type of dictionary, but I do not understand how to use it in a practical way. {b'827544c22ccfd904807ebb0d430660785c5c6dd9': {b'download_location': b'/media/luiz/HD/MIDIA/SERIES/Radiant/Season 2', b'hash': b'827544c22ccfd904807ebb0d430660785c5c6dd9', b'move_on_completed_path': b'/media/luiz/HD/MIDIA/SERIES/Radiant/Season 2', b'state': b'Error', b'progress': 100.0, b'move_on_completed': False}}

JohnDoee commented 4 years ago

I'm not sure what exactly the problem is, you can just use the dictionary as you'd use any dictionary in Python.

It seems like you either are not sure what your project goal is or your actual Python knowledge should be improved. Both of those are not bugs or feature requests though.

luizoti commented 4 years ago

Exactly, at no point did I say there was a bug or function request, I questioned the method of use.

As already requested, it would be useful for a wiki, even if basic, about the methods that can be used.

As I said, I can generate the dictionary, but no, in my tests it does not work as a standard dictionary.

As far as I understand this use should work and the result would be the hash, not the KeyError.


Traceback (most recent call last):
  File "/home/luiz/wifi.py", line 9, in <module>
    x = torrents["hash"]
KeyError: 'hash'
from deluge_client import DelugeRPCClient

deluge = DelugeRPCClient('127.0.0.1', 58846, 'localclient', 'admin')
deluge.connect()
deluge.connected

torrents = deluge.call('core.get_torrents_status', {}, ['hash', 'move_on_completed_path', 'move_on_completed', 'progress', 'download_location', 'state'])

x = torrents["hash"]

print(x)

deluge.disconnect()