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 »

Ah sorry, I gave you the wrong method, it's auth.login, must've been having a sleepy moment. Apologies.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Okay, so I am using 'auth.login' now, which returns:

Code: Select all

{"id": 1, "result": true, "error": null}
And indeed it also returns a header row for the cookie:

Code: Select all

Transfer-Encoding: chunked, 
Date: Wed, 02 Sep 2009 12:02:59 GMT, 
Content-Type: application/x-json, 
Server: TwistedWeb/8.2.0, 
Set-Cookie: _session_id=ccc63c79be099e69279f3418fe9f6bc52324; Expires=Wed, 02 Sep 2009 13:02:59 UTC; Path=/json
EDIT: What cookie specification did you use? My HttpClient (Apache Commons) gives a parse error:

Code: Select all

Invalid cookie header: "Set-Cookie: _session_id=7f85f51a950d854df35fd07a620dd0d62248; Expires=Wed, 02 Sep 2009 13:42:13 UTC; Path=/json". Unable to parse expires attribute: Wed, 02 Sep 2009 13:42:13 UTC
I think their should be - signs between 02-Sep-2009?
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 »

According to:
http://www.w3.org/Protocols/rfc2616/rfc ... tml#sec3.3

It should be absolutely fine. Only thing I can think of is that it isn't liking the UTC timezone, would you mind trying to change it to GMT to see if that solves the situation?

The dates are formed on lines 128 and 227 in deluge/ui/web/auth.py.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Jup, that worked! I replaced the hard-coded 'UTC' text with 'GMT'. (In my SVN version of auth.py, it was only in line 128.)

I now get a cookie:

Code: Select all

Set-Cookie: _session_id=ee26b4ae24a71aae5935a47f3ba80f222324; Expires=Thu, 03 Sep 2009 10:08:24 GMT; Path=/json
Which the Apache HttpClient parses just fine. And indeed I get authenticated correctly by Deluge, returning the torrent listing again.
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 »

Brilliant, well just commited a fix changing this for everyone now!
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

So, it seems I have another issue with my Deluge support. I'm not sure if you've noticed at all, but removing of torrents doesn't work any more.

Actually, when I try to remove a torrent, it sends this RPC command:

Code: Select all

{"method":"core.remove_torrent","params":[["60d5d82328b4547511fdeac9bf4d0112daa0ce00"],false],"id":2}
The Deluge server now doesn't respond, but an error message is show on the command line output:

Code: Select all

[ERROR   ] 11:24:11 client:375 RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: core.remove_torrent([u'60d5d82328b4547511fdeac9bf4d0112daa0ce00'], False)
--------------------------------------------------------------------------------
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/core/rpcserver.py", line 281, 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 288, in remove_torrent
    return self.torrentmanager.remove(torrent_id, remove_data)
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.2.0_dev-py2.6.egg/deluge/core/torrentmanager.py", line 479, in remove
    raise InvalidTorrentError("torrent_id not in session")

InvalidTorrentError: torrent_id not in session
Since the torrents are retrieved from the server with exactly that ID, I am sure that it exists. It seems I do not have control over it from this session or something. The source code or torrentmanager.py also didn't give me any hints. Any ideas?
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 »

Ahh, all the *_torrent functions where changed from accepting a list of ids to just a single id.

We have actually (finally) produced some documentation now: http://deluge-torrent.org/docs/1.2/core ... remote-api

That's only for the core, I still need to have some generating for the additional web api methods.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Thanks for that reply. I changed the method call and it works again.
ElmoTheElk
Member
Member
Posts: 25
Joined: Tue May 12, 2009 5:27 pm

Re: Android, Remote Only Client

Post by ElmoTheElk »

Back again with another question! :-)

I am implementing support in my Android app to allow user to set the maximum transfer rates (download and upload). Here is the JSON request I am sending to Deluge:

Code: Select all

{"id":2,"method":"core.set_config","params":[[{"max_upload_speed":2},{"max_download_speed":1}]]}
But then Deluge spits out an error to my console:

Code: Select all

[ERROR   ] 10:29:02 client:375 RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: core.set_config([{u'max_upload_speed': 2}, {u'max_download_speed': 1}])
--------------------------------------------------------------------------------
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.3.0_dev-py2.6.egg/deluge/core/rpcserver.py", line 281, in dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.3.0_dev-py2.6.egg/deluge/core/core.py", line 478, in set_config
    for key in config.keys():

AttributeError: 'tuple' object has no attribute 'keys'
Probably I should send the JSON data in some different format, but I'm not sure how. (I tried several options myself.) Can you provide me an example JSON request string for the set_config method?
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 »

ElmoTheElk wrote:Back again with another question! :-)

I am implementing support in my Android app to allow user to set the maximum transfer rates (download and upload). Here is the JSON request I am sending to Deluge:

Code: Select all

{"id":2,"method":"core.set_config","params":[[{"max_upload_speed":2},{"max_download_speed":1}]]}
But then Deluge spits out an error to my console:

Code: Select all

[ERROR   ] 10:29:02 client:375 RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: core.set_config([{u'max_upload_speed': 2}, {u'max_download_speed': 1}])
--------------------------------------------------------------------------------
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.3.0_dev-py2.6.egg/deluge/core/rpcserver.py", line 281, in dispatch
    ret = self.factory.methods[method](*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/deluge-1.3.0_dev-py2.6.egg/deluge/core/core.py", line 478, in set_config
    for key in config.keys():

AttributeError: 'tuple' object has no attribute 'keys'
Probably I should send the JSON data in some different format, but I'm not sure how. (I tried several options myself.) Can you provide me an example JSON request string for the set_config method?
You've got one too many [] around the params, should be params: [{.....}], not params: [[{....}]] :)
Post Reply