Page 1 of 1

Can't start/pause a single torrent via RPC ?

Posted: Fri Aug 05, 2016 12:10 pm
by iBroken
Hello

let's use curl to do this

first you need to set the cookies, my password is `deluge`

Code: Select all

curl -c cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "auth.login", "params": ["deluge"], "id": 1}' http://localhost:8112/json
now you can stop all the torrents (which works) with:

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "core.pause_all_torrents", "params": [], "id": 2}' http://localhost:8112/json
start them all again (which works also) with :

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "core.resume_all_torrents", "params": [], "id": 3}' http://localhost:8112/json
now if you try to stop a single torrent, you need to provide its hash in the `params`, I tried the following:

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "core.pause_torrent", "params": ["7344bac975ee260aa59bb1b0c1116371b58fa147"], "id": 4}' http://localhost:8112/json
but it never returns anything. also the `core.resume_torrent` has the same problem, maybe I'm not using them right ?

also, fun fact, if you pause all the torrents via curl, you won't be able to start them via the WebUI, and vise versa, why ? no one knows :mrgreen:

Re: Can't start/pause a single torrent via RPC ?

Posted: Fri Aug 05, 2016 8:05 pm
by Cas
Curl hanging on the request rather than returning a success/fail message indicates there is an issue with the actual request. So there is no issue with pausing a torrent via RPC, the problem is that the params contains a string but the method requires a list (of strings):

Code: Select all

"params": [["<torrent_id"]]
iBroken wrote: fun fact, if you pause all the torrents via curl, you won't be able to start them via the WebUI, and vise versa, why ? no one knows :mrgreen:
Yes the pause all torrent was changed in 1.3.13 to pause the session and perhaps in hindsight I should have kept the original functionality and added a new method to the api, there is a ticket which touches on this: http://dev.deluge-torrent.org/ticket/2866

Re: Can't start/pause a single torrent via RPC ?

Posted: Fri Aug 05, 2016 9:36 pm
by iBroken
@Cas thank you for clearing that up, it works for me now, however, curl hanging on the request doesn't always mean that there's a problem with the request, for instance, try removing a torrent that doesn't exist by providing the wrong hash, curl will hang

Code: Select all

curl -b cookies.txt --compressed -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"method": "core.remove_torrent", "params": ["7344bac975ee260aa59bb1b0c0006371b58fa147", true], "id": 4}' http://localhost:8112/json
if the torrent exists, everything will be fine.

one more question, is there a good RPC reference ? all the docs that I can find on the net are vague to say the least.

Re: Can't start/pause a single torrent via RPC ?

Posted: Fri Aug 05, 2016 10:11 pm
by Cas
The docs build for 1.3 is broken iirc so the source code is best reference, anything with @export.

There are docs for develop, the code has diverged a bit but not hugely API-wise: http://deluge.readthedocs.io/en/develop/

Re: Can't start/pause a single torrent via RPC ?

Posted: Sat Aug 06, 2016 2:14 am
by iBroken
thank you for the valuable information, one more question, are the methods returned by `daemon.get_method_list` comprehensive ? or I should look elsewhere for more methods.

Code: Select all

{"id": 1, "result": ["core.upload_plugin", "core.rescan_plugins", "core.force_recheck", "core.glob", "core.remove_torrent", "core.resume_all_torrents", "core.queue_top", "daemon.get_method_list", "ltconfig.get_settings", "core.set_torrent_options", "core.set_torrent_prioritize_first_last", "core.get_session_state", "core.set_torrent_move_completed", "core.get_available_plugins", "core.set_torrent_file_priorities", "core.get_config", "core.disable_plugin", "core.test_listen_port", "core.connect_peer", "core.enable_plugin", "core.get_filter_tree", "ltconfig.get_original_settings", "core.set_torrent_remove_at_ratio", "core.get_torrent_status", "core.get_config_values", "core.pause_torrent", "core.move_storage", "core.force_reannounce", "core.add_torrent_file", "core.get_listen_port", "core.set_torrent_move_completed_path", "core.set_torrent_stop_at_ratio", "core.rename_folder", "core.add_torrent_url", "core.get_enabled_plugins", "core.get_libtorrent_version", "core.get_path_size", "core.set_torrent_max_connections", "core.get_config_value", "core.get_session_status", "core.create_torrent", "core.add_torrent_magnet", "daemon.info", "core.set_torrent_stop_ratio", "core.set_torrent_auto_managed", "core.pause_all_torrents", "ltconfig.get_preferences", "core.get_torrents_status", "core.rename_files", "core.get_free_space", "core.queue_bottom", "core.set_torrent_max_upload_speed", "ltconfig.get_preset", "ltconfig.set_preferences", "core.resume_torrent", "core.set_torrent_max_upload_slots", "core.set_config", "core.get_cache_status", "core.queue_down", "daemon.shutdown", "core.get_num_connections", "core.set_torrent_max_download_speed", "core.queue_up", "core.set_torrent_trackers"], "error": null}