Please Read our FAQ
import xmlrpclibfrom pprint import pprints = xmlrpclib.ServerProxy("http://localhost:6800/rpc")r = s.aria2.addUri(["http://localhost/aria2.tar.bz2"], {"dir":"/downloads"})pprint(r)
aria2c --enable-xml-rpc
First, run aria2 with --enable-xml-rpc:
[ahmed@Lenovo src]$ aria2c --enable-xml-rpc --xml-rpc-listen-all --xml-rpc-listen-port=68012010-02-14 03:01:53.867532 WARN - You may encounter the certificate verification error with HTTPS server. See --ca-certificate and --check-certificate option. 2010-02-14 03:01:57.307837 NOTICE - Shutdown sequence commencing... Press Ctrl-C again for emergency shutdown.Download Results:gid|stat|avg speed |path/URI===+====+===========+===========================================================
# Launch aria2c process begin command = "aria2c --disable-ipv6=true " \ "--enable-xml-rpc --xml-rpc-listen-port=#{@port} " \ "--conf-path=#{@confdir}/aria2.conf --log=#{@confdir}/aria2.log --log-level=notice " \ "--dht-file-path=#{@confdir}/dht.dat" @@pid = spawn_server(command)
=begin spawn_server: Execute an aria2c process in background and wait for a positive response.=end def spawn_server(command) pid = Process.spawn(command, :pgroup=>true, :chdir=>ENV['HOME'], STDOUT=>"/dev/null", STDIN=>"/dev/null") Process.detach(pid) # Wait for the server to respond properly to requests debug("waiting for a first response...") Timeout::timeout(5) do begin begin result = @@client.call("aria2.tellActive") rescue end sleep 1 if result == nil end while result == nil end debug("started server", command, pid) pid end
>>> import os>>> os.system('aria2c -D --enable-xml-rpc') #starting as Daemon.0>>> import xmlrpclib>>> from pprint import pprint>>> s=xmlrpclib.ServerProxy('http://localhost:6800/rpc')>>> s<ServerProxy for localhost:6800/rpc>>>> s.aria2.getVersion(){'version': '1.6.3', 'enabledFeatures': ['Async DNS', 'BitTorrent', 'Firefox3 Cookie', 'GZip', 'HTTPS', 'Message Digest', 'Metalink', 'XML-RPC']}>>> s.aria2.addUri(['http://services.netbeans.org/bouncer/index.php?product=netbeans-6.8-ml-javase&os=linux'], {'dir':'/home/xmonader/' } )'2'>>> s.aria2.tellActive()[{'status': 'active', 'numPieces': '47', 'downloadSpeed': '118786', 'pieceLength': '1048576', 'bitfield': '000000000000', 'connections': '5', 'gid': '2', 'completedLength': '393216', 'uploadSpeed': '0', 'uploadLength': '0', 'totalLength': '49047552'}]>>> s.aria2.tellActive()[{'status': 'active', 'numPieces': '47', 'downloadSpeed': '121583', 'pieceLength': '1048576', 'bitfield': '000000000000', 'connections': '5', 'gid': '2', 'completedLength': '540672', 'uploadSpeed': '0', 'uploadLength': '0', 'totalLength': '49047552'}]