I am trying to orchestrate a downloading of files with aria2 tool. There is an example in the documentation like:
import urllib2, json
jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
'method':'aria2.addUri',
'params':[['http://example.org/file']]})
c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
c.read()
# The result:
# '{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'
It starts download of http://example.org/file and returns some GID (download ID) 2089b05ecca3d829...
Aria2 supports notifications. But no any examples how to get a notification, for example, onDownloadComplete, onDownloadError, etc. I assume, there is a way to request the aria2 to call me through JSON-RPC (HTTP) on some (my) IP and port. But I cannot find a way how to request aria2 to do it (how to subscribe to the notifications with my IP, port). Any example in Python, Ruby or similar will be very helpful.
Refered to aria2 docs You should use websocket to communicate with RPC server:
after you get the message (json object), you'll get the onDownloadComplete event, then you can do whatever you like. I suggest you use ariap (above @RandomB Mentioned it), https://pawamoy.github.io/aria2p/reference/api/#aria2p.api.API.listen_to_notifications
set notification with a callback.