Android, Remote Only Client

Suggestions and discussion of future versions
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Android, Remote Only Client

Post by damoxc »

The request should look something along the lines of:

Code: Select all

{
    "id": 1,
    "method": "auth.login",
    "params": ["password"]
}
I used version 1.1 of the json-rpc spec so kwargs aren't supported, purely positional.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Thanks damoxc! I'll give it a try today. Hope I can get Deluge support up and running quickly. Just have to compile Deluge 1.2 first. :-)

Eric
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Wow, it is starting to work...

Deluge 1.2 is build and working. Nice web ui work by the way... (It works in the Android browser, albeit not very handy on such a small screen.)

The request that you specified works. I did have to find out by looking through some codes that the request should now be made to '/json/ and no longer to '/json/rpc'. Maybe update the docs?

Thanks so far for the quick support. I'll let you know when my app is capable of talking to Deluge.
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Android, Remote Only Client

Post by damoxc »

Post it somewhere so I can give it a test :)
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

I continued my work on Deluge support in my app, and progress is steady, albeit pretty slow. I have 1 question and 1 problem. To begin with the problem ;-) ...

The methods exposed by system.listMethods seem to work indeed. I am currently using auth.login and web.update_ui that succesfully understand my requests and send nice response. However, any of the other methods that are not 'json specific' are not listed by system.listMethods and I can't seem to call them. For example add_torrent_url, remove_torrent, pause_torrent, pause_all_torrents, resume_torrent and resume_all_torrents. I tried to call them using their plain name, or in a . notation. But nothing works (like 'add_torrent_url', 'sclient.add_torrent_url' or 'client.add_torrent_url'). Do I need a different namespace (or whatever it is called in Python...)? Or is it by design that these methods cannot be called. Since the AJAX web template can use them, I presume I just don't know the proper method call... The error I get when calling a method add_torrent_url, for example, look like:

Code: Select all

[ERROR   ] 15:22:19 json_api:214 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/ui/web/json_api.py", line 236, in render
    d = self._on_json_request(request)
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/ui/web/json_api.py", line 205, in _on_json_request
    d, response["id"] = self._handle_request(request.json)
TypeError: 'NoneType' object is not iterable
A question about auth.login: what is it's function? Do I need to call this once? How does it remember my session? How often should it be called then? In general, how does authentication work?

Thanks a lot for the help so far. A very VERY preliminary can be downloaded here: http://ekok.nl/download/transdroid-0.7.0.apk This should work with Deluge 1.2's web ui, but ONLY the listing of the torrents and no actions like pause, resume or add, since I can't seem to get the proper method calls as explained...
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Android, Remote Only Client

Post by damoxc »

Right, auth.login returns a session_id (that I store as a cookie using javascript).

system.listMethods returns the methods added to the webui ("local methods") and once connected to a deamon it also returns the additional methods (core.xyz and daemon.xyz).

The session support is pretty moot at the moment so I wouldn't worry about that too much.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Thanks again! Torrent adding, pausing all and resuming all now works as well.

The only problem I have left now, is that I am not sure how to send torrent ID's. For example, to pause a single torrent, I send this request:

Code: Select all

{"method":"core.pause_torrent","params":["60d5d82328b4547511fdeac9bf4d0112daa0ce00"],"id":2}
But error that it logged is:

Code: Select all

[ERROR   ] 17:15:17 client:364 RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: core.pause_torrent(60d5d82328b4547511fdeac9bf4d0112daa0ce00)
--------------------------------------------------------------------------------
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/core/rpcserver.py", line 257, in _dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/core/core.py", line 338, in pause_torrent
    if not self.torrentmanager[torrent_id].pause():
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/core/torrentmanager.py", line 233, in __getitem__
    return self.torrents[torrent_id]

KeyError: 6
--------------------------------------------------------------------------------
So it seems that it gets recognised as a proper id array, but later the torrent id is not in the daemon's internal torrent list.
Sorry to ask so many question. This really seems like the very final step. :-)
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Android, Remote Only Client

Post by damoxc »

Ok, that's not actually a list of torrent ids, that's just a single torrent id string, which when it gets iterated over of course it's on a character level, hence why you get the KeyError, 6.

Here is the correct request:

Code: Select all

{"method":"core.pause_torrent","params":[["60d5d82328b4547511fdeac9bf4d0112daa0ce00"]],"id":2}
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Ah I see. Pretty obvious... I'll give it a try tonight (or tomorrow).

You said you'd give it a try; do you own an Android device yourself?
damoxc
Top Bloke
Top Bloke
Posts: 117
Joined: Sat Jul 19, 2008 7:26 pm
Location: Hampshire, UK
Contact:

Re: Android, Remote Only Client

Post by damoxc »

Yup, got a G1 when they first came out :)
Post Reply