JohnDoee / deluge-client

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

Unable to get specifc torrent stat #8

Closed http403 closed 6 years ago

http403 commented 6 years ago

I'm trying to get a specific torrent data using core.get_torrent_status. However, no matter what I put into the arguments, it return a empty dictionary.

Here're some scripts I tried:

1.

from client import DelugeRPCClient

client = DelugeRPCClient('127.0.0.1', 12345, 'user', 'pass', True)
client.connect()

response = client.call('core.get_torrent_status' , ['53c17c8ab411ce3c79bc29addeb04047921d5c27'], {})

print(response)

2.

from client import DelugeRPCClient

client = DelugeRPCClient('127.0.0.1', 12345, 'user', 'pass', True)
client.connect()

response = client.call('core.get_torrent_status' , [], {'filter_dict': {'torrent_id': '53c17c8ab411ce3c79bc29addeb04047921d5c27'}})

print(response)

3.

import json
from client import DelugeRPCClient

client = DelugeRPCClient('127.0.0.1', 12345, 'user', 'pass', True)
client.connect()
request = """
{
    "filter_dict": {
        "torrent_id": "53c17c8ab411ce3c79bc29addeb04047921d5c27"
    }
}
"""
response = client.call('core.get_torrent_status' , [], json.loads(request))

print(response)

4.

from client import DelugeRPCClient

client = DelugeRPCClient('127.0.0.1', 12345, 'user', 'pass', True)
client.connect()

response = client.call('core.get_torrent_status' , {}, ['53c17c8ab411ce3c79bc29addeb04047921d5c27'])

print(response)

Am I did something wrong? How can I make it work?

JohnDoee commented 6 years ago

The signature for core.get_torrent_status can be found here: https://github.com/deluge-torrent/deluge/blob/26441693769047b460a46faf8a2440896bbd3c79/deluge/core/core.py#L601

That means you'd call it like this

get_torrent_status('53c17c8ab411ce3c79bc29addeb04047921d5c27', [])

That translate into

client.call('core.get_torrent_status', '53c17c8ab411ce3c79bc29addeb04047921d5c27', [])

The filter_dict is an argument for get_torrents_status (notice the plural torrentS) and can be used like this.

get_torrents_status({'id': '53c17c8ab411ce3c79bc29addeb04047921d5c27'}, [])

which translates into

client.call('core.get_torrents_status', {'id': '53c17c8ab411ce3c79bc29addeb04047921d5c27'}, [])

The syntax design is very similar to the one used in Twisted Python where function_name(args, kwargs) is translated into wrapper(function_name, args, kwargs).