我正在尝试使用aria2工具来协调文件的下载。文档中有一个示例,例如:
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"}'
它开始下载http://example.org/file
并返回一些 GID(下载 ID)2089b05ecca3d829
......
Aria2 支持通知。但是没有任何示例如何获取通知,例如onDownloadComplete、onDownloadError等。我认为,有一种方法可以请求 aria2 通过 JSON-RPC (HTTP) 在某些(我的)IP 和端口上呼叫我。但是我找不到如何请求 aria2 来完成它的方法(如何使用我的 IP、端口订阅通知)。Python、Ruby 或类似的任何示例都会非常有帮助。