Provided by:
aria2_1.13.0-1_i386 
RPC-
aria2 JSON-RPC XML-RPC, .
JSON-RPC- - /jsonrpc. XML-RPC- - /rpc.
JSON-RPC JSON-RPC 2.0 (2010-03-26) HTTP POST GET (JSONP).
JSON-RPC- . . UTF-8.
JSON-RPC, JSON-.
GID
GID ( gid) - , . GID. GID , , .. . ,
GID aria2.
Python2.7.
aria2.addUri (uris[, options[, position]])
HTTP(S)/FTP/BitTorrent Magnet URI. uris , URI.
BitTorrent Magnet URI, uris , BitTorrent Magnet URI. URI
uris . URI, , aria2 , . options , .
. position , 0, position . position ,
. GID .
http://example.org/file 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()
'{"id":"qwer","jsonrpc":"2.0","result":"1"}'
http://example.org/file aria2:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.addUri(['http://example.org/file'])
'1'
:
>>> s.aria2.addUri(['http://example.org/file', 'http://mirror/file'],
dict(dir="/tmp"))
'2'
:
>>> s.aria2.addUri(['http://example.org/file'], {}, 0)
'3'
aria2.addTorrent (torrent[, uris[, options[, position]]])
BitTorrent- .torrent-. BitTorrent Magnet URI,
aria2.addUri. torrent base64, Base64- . .torrent-. uris ,
URI. uris Web-. , URI , , /, torrent-. ,
URI . options , . . position , 0,
position . position , . GID . SHA-1-
".torrent", --dir. ,
0a3893293e27ac0490424c06de4d09242215f0a6.torrent. , . ,
, , --save-session.
file.torrent aria2:
>>> import urllib2, json, base64
>>> torrent = base64.b64encode(open('file.torrent').read())
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'asdf',
... 'method':'aria2.addTorrent', 'params':[torrent]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> c.read()
'{"id":"asdf","jsonrpc":"2.0","result":"6"}'
file.torrent aria2:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
'6'
aria2.addMetalink (metalink[, options[, position]])
Metalink- .metalink-. metalink base64, Base64-
.metalink-. options , -. . position , 0,
position . position , . GID . SHA-1-
".metalink", --dir. ,
0a3893293e27ac0490424c06de4d09242215f0a6.metalink. , .
, , , --save-session.
file.meta4 aria2:
>>> import urllib2, json, base64
>>> metalink = base64.b64encode(open('file.meta4').read())
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.addMetalink', 'params':[metalink]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> c.read()
'{"id":"qwer","jsonrpc":"2.0","result":["8"]}'
file.meta4 aria2:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.addMetalink(xmlrpclib.Binary(open('file.meta4').read()))
['8']
aria2.remove (gid)
, gid. gid . , , . "removed" (). GID .
, GID "3":
>>> import urllib2, json
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.remove', 'params':['3']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> c.read()
'{"id":"qwer","jsonrpc":"2.0","result":"3"}'
, GID "3":
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.remove('3')
'3'
aria2.forceRemove (gid)
, gid. aria2.remove, , - , , BitTorrent-.
aria2.pause (gid)
, gid. gid . "paused" (). , . "paused", .
"waiting", aria2.unpause. GID .
aria2.pauseAll ()
aria2.pause, / . "OK", .
aria2.forcePause (pid)
, gid. aria2.pause, , - , , BitTorrent-.
aria2.forcePauseAll ()
aria2.forcePause, / . "OK", .
aria2.unpause (gid)
, gid, "paused" "waiting". . gid . GID, , .
aria2.unpauseAll ()
aria2.unpause, / . "OK", .
aria2.tellStatus (gid[, keys])
, gid. gid . keys . keys , keys. keys ,
. , , . , aria2.tellStatus("1", ["gid", "status"]) gid
status. . .
gid
GID .
status
"active" - / . "waiting" - ; . "paused" - . "error" - ,
.. . "complete" - . "removed" - .
totalLength
.
completedLength
.
uploadLength
.
bitfield
. 0. , , . 0. , .
downloadSpeed
/.
uploadSpeed
/.
infoHash
(InfoHash). BitTorrent.
numSeeders
, . BitTorrent.
pieceLength
.
numPieces
.
connections
/, .
errorCode
, . . . / .
followedBy
GID, . , aria2 Metalink-, , (.
--follow-metalink). . , .
belongsTo
GID . . , Metalink BitTorrent-, .torrent .
, .
dir
. .
files
. - , , aria2.getFiles.
bittorrent
, , .torrent-. BitTorrent. .
announceList
URI . .torrent- , -, -.
comment
. comment.utf-8, .
creationDate
. , , .
mode
. : single () multi ().
info
, Info. .
name
info. name.utf-8, .
, GID "1":
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.tellStatus', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'bitfield': u'0000000000',
u'completedLength': u'901120',
u'connections': u'1',
u'dir': u'/downloads',
u'downloadSpeed': u'15158',
u'files': [{u'index': u'1',
u'length': u'34896138',
u'completedLength': u'34896138',
u'path': u'/downloads/file',
u'selected': u'true',
u'uris': [{u'status': u'used',
u'uri': u'http://example.org/file'}]}],
u'gid': u'1',
u'numPieces': u'34',
u'pieceLength': u'1048576',
u'status': u'active',
u'totalLength': u'34896138',
u'uploadLength': u'0',
u'uploadSpeed': u'0'}}
, :
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.tellStatus',
... 'params':['1', ['gid',
... 'totalLength',
... 'completedLength']]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'completedLength': u'5701632',
u'gid': u'1',
u'totalLength': u'34896138'}}
, GID "1":
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.tellStatus('1')
>>> pprint(r)
{'bitfield': 'ffff80',
'completedLength': '34896138',
'connections': '0',
'dir': '/downloads',
'downloadSpeed': '0',
'errorCode': '0',
'files': [{'index': '1',
'length': '34896138',
'completedLength': '34896138',
'path': '/downloads/file',
'selected': 'true',
'uris': [{'status': 'used',
'uri': 'http://example.org/file'}]}],
'gid': '1',
'numPieces': '17',
'pieceLength': '2097152',
'status': 'complete',
'totalLength': '34896138',
'uploadLength': '0',
'uploadSpeed': '0'}
, :
>>> r = s.aria2.tellStatus('1', ['gid', 'totalLength', 'completedLength'])
>>> pprint(r)
{'completedLength': '34896138', 'gid': '1', 'totalLength': '34896138'}
aria2.getUris (gid)
URI, , gid. gid . , - . .
uri
URI
status
used, URI . waiting, URI .
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getUris', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': [{u'status': u'used',
u'uri': u'http://example.org/file'}]}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getUris('1')
>>> pprint(r)
[{'status': 'used', 'uri': 'http://example.org/file'}]
aria2.getFiles (gid)
, gid. gid . , - . .
index
. 1. , .
path
.
length
.
completedLength
. , , completedLength aria2.tellStatus. ,
completedLength aria2.getFiles . , completedLength
aria2.tellStatus .
selected
"true" - --select-file. --select-file , "true".
"false".
uris
URI . , aria2.getUris.
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getFiles', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': [{u'index': u'1',
u'length': u'34896138',
u'completedLength': u'34896138',
u'path': u'/downloads/file',
u'selected': u'true',
u'uris': [{u'status': u'used',
u'uri': u'http://example.org/file'}]}]}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getFiles('1')
>>> pprint(r)
[{'index': '1',
'length': '34896138',
'completedLength': '34896138',
'path': '/downloads/file',
'selected': 'true',
'uris': [{'status': 'used',
'uri': 'http://example.org/file'}]}]
aria2.getPeers (gid)
, gid. gid . BitTorrent. , - . .
peerId
ID .
ip
IP- .
port
.
bitfield
. 0. , , . 0.
amChoking
"true" - . "false".
peerChoking
"true" - . "false".
downloadSpeed
(/), .
uploadSpeed
(/), .
seeder
"true" - . "false".
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getPeers', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': [{u'amChoking': u'true',
u'bitfield': u'ffffffffffffffffffffffffffffffffffffffff',
u'downloadSpeed': u'10602',
u'ip': u'10.0.0.9',
u'peerChoking': u'false',
u'peerId': u'aria2%2F1%2E10%2E5%2D%87%2A%EDz%2F%F7%E6',
u'port': u'6881',
u'seeder': u'true',
u'uploadSpeed': u'0'},
{u'amChoking': u'false',
u'bitfield': u'ffffeff0fffffffbfffffff9fffffcfff7f4ffff',
u'downloadSpeed': u'8654',
u'ip': u'10.0.0.30',
u'peerChoking': u'false',
u'peerId': u'bittorrent client758',
u'port': u'37842',
u'seeder': u'false',
u'uploadSpeed': u'6890'}]}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getPeers('1')
>>> pprint(r)
[{'amChoking': 'true',
'bitfield': 'ffffffffffffffffffffffffffffffffffffffff',
'downloadSpeed': '10602',
'ip': '10.0.0.9',
'peerChoking': 'false',
'peerId': 'aria2%2F1%2E10%2E5%2D%87%2A%EDz%2F%F7%E6',
'port': '6881',
'seeder': 'true',
'uploadSpeed': '0'},
{'amChoking': 'false',
'bitfield': 'ffffeff0fffffffbfffffff9fffffcfff7f4ffff',
'downloadSpeed': '8654',
'ip': '10.0.0.30',
'peerChoking': 'false',
'peerId': 'bittorrent client758',
'port': '37842',
'seeder': 'false,
'uploadSpeed': '6890'}]
aria2.getServers (gid)
HTTP(S)/FTP- , gid. gid . , - . .
index
. 1. , .
servers
, .
uri
URI.
currentUri
URI . , currentUri uri .
downloadSpeed
(/)
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getServers', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': [{u'index': u'1',
u'servers': [{u'currentUri': u'http://example.org/file',
u'downloadSpeed': u'10467',
u'uri': u'http://example.org/file'}]}]}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getServers('1')
>>> pprint(r)
[{'index': '1',
'servers': [{'currentUri': 'http://example.org/dl/file',
'downloadSpeed': '20285',
'uri': 'http://example.org/file'}]}]
aria2.tellActive ([keys])
. , aria2.tellStatus. keys,
aria2.tellStatus.
aria2.tellWaiting (offset, num, [keys])
, . offset , . num . keys,
aria2.tellStatus.
, [offset, offset+num).
offset . offset == -1 , , offset == -2 , . .
, , "A","B" "C", , . aria2.tellWaiting(0, 1) ["A"].
aria2.tellWaiting(1, 2) ["B", "C"]. aria2.tellWaiting(-1, 2)
["C", "B"].
, aria2.tellStatus.
aria2.tellStopped (offset, num, [keys])
. offset , . num . keys,
aria2.tellStatus.
offset num aria2.tellWaiting.
, aria2.tellStatus.
aria2.changePosition (gid, pos, how)
, gid. pos . how . how - "POS_SET", , . how -
"POS_CUR", , . how - "POS_END", , . 0 ,
. .
, GID#1 3, aria2.changePosition(1, -1, POS_CUR) 2.
aria2.changePosition(1, 0, POS_SET) 0 ( ).
, GID "3", :
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.changePosition',
... 'params':['3', 0, 'POS_SET']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': 0}
, GID "3", :
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.changePosition('3', 0, 'POS_SET')
0
aria2.changeUri (gid, fileIndex, delUris, addUris[, position])
URI delUris URI addUris , gid. delUris addUris .
URI . fileIndex , / URI. fileIndex 1. position , URI
URI. position 0. position , URI . , . position URI,
, , . URI, URI , , URI delUris. , URI
"http://example.org/aria2" , ( ) 3
"http://example.org/aria2" delUris. , 2 . - URI. -
URI.
1 URI http://example.org/file "1", , GID "2":
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.changeUri',
... 'params':['2', 1, [], ['http://example.org/file']]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': [0, 1]}
1 URI http://example.org/file "1", , GID "2":
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.changeUri('2', 1, [], ['http://example.org/file'])
[0, 1]
aria2.getOption (gid)
, gid. . - . .
, GID "1":
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getOption', 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'allow-overwrite': u'false',
u'allow-piece-length-change': u'false',
u'always-resume': u'true',
u'async-dns': u'true',
...
, GID "1":
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getOption('1')
>>> pprint(r)
{'allow-overwrite': 'false',
'allow-piece-length-change': 'false',
'always-resume': 'true',
'async-dns': 'true',
....
aria2.changeOption (gid, options)
, gid. gid . options , : bt-max-peers,
bt-request-peer-speed-limit, max-download-limit max-upload-limit.
"OK", .
max-download-limit "20K" , GID "1":
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.changeOption',
... 'params':['1', {'max-download-limit':'10K'}]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'OK'}
max-download-limit "20K" , GID "1":
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.changeOption('1', {'max-download-limit':'20K'})
'OK'
aria2.getGlobalOption ()
. . - . . , aria2.getOption.
aria2.changeGlobalOption (options)
. options , : max-concurrent-downloads,
max-overall-download-limit, max-overall-upload-limit, log-level
log. log, . ("") . , . "OK",
.
aria2.getGlobalStat ()
. . .
downloadSpeed
(/).
uploadSpeed
(/).
numActive
.
numWaiting
.
numStopped
.
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getGlobalStat'})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'downloadSpeed': u'21846',
u'numActive': u'2',
u'numStopped': u'0',
u'numWaiting': u'0',
u'uploadSpeed': u'0'}}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getGlobalStat()
>>> pprint(r)
{'downloadSpeed': '23136',
'numActive': '2',
'numStopped': '0',
'numWaiting': '0',
'uploadSpeed': '0'}
aria2.purgeDownloadResult ()
, , // . "OK".
aria2.removeDownloadResult (gid)
// , gid. "OK", .
, GID "1":
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.removeDownloadResult',
... 'params':['1']})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'OK'}
, GID "1":
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.removeDownloadResult('1')
'OK'
aria2.getVersion ()
. .
version
.
enabledFeatures
. .
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getVersion'})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'enabledFeatures': [u'Async DNS',
u'BitTorrent',
u'Firefox3 Cookie',
u'GZip',
u'HTTPS',
u'Message Digest',
u'Metalink',
u'XML-RPC'],
u'version': u'1.11.0'}}
>>> import xmlrpclib
>>> from pprint import pprint
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> r = s.aria2.getVersion()
>>> pprint(r)
{'enabledFeatures': ['Async DNS',
'BitTorrent',
'Firefox3 Cookie',
'GZip',
'HTTPS',
'Message Digest',
'Metalink',
'XML-RPC'],
'version': '1.11.0'}
aria2.getSessionInfo ()
. .
sessionId
ID , , aria2.
>>> import urllib2, json
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.getSessionInfo'})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer',
u'jsonrpc': u'2.0',
u'result': {u'sessionId': u'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}}
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.getSessionInfo()
{'sessionId': 'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}
aria2.shutdown ()
aria2. "OK".
aria2.forceShutdown ()
aria2. aria2.shutdown, , - , , BitTorrent- .
"OK".
system.multicall (methods)
. methods , . : "methodName" "params".
"methodName" - , "params" - . . : , ,
, .
2 . - http://example.org/file - file.torrent:
>>> import urllib2, json, base64
>>> from pprint import pprint
>>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
... 'method':'system.multicall',
... 'params':[[{'methodName':'aria2.addUri',
... 'params':[['http://example.org']]},
... {'methodName':'aria2.addTorrent',
... 'params':[base64.b64encode(open('file.torrent').read())]}]]})
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': [[u'1'], [u'2']]}
JSON-RPC , JSON-RPC 2.0:
>>> jsonreq = json.dumps([{'jsonrpc':'2.0', 'id':'qwer',
... 'method':'aria2.addUri',
... 'params':[['http://example.org']]},
... {'jsonrpc':'2.0', 'id':'asdf',
... 'method':'aria2.addTorrent',
... 'params':[base64.b64encode(open('file.torrent').read())]}])
>>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
>>> pprint(json.loads(c.read()))
[{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'1'},
{u'id': u'asdf', u'jsonrpc': u'2.0', u'result': u'2'}]
2 . - http://example.org/file - file.torrent:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> mc = xmlrpclib.MultiCall(s)
>>> mc.aria2.addUri(['http://example.org/file'])
>>> mc.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
>>> r = mc()
>>> tuple(r)
('2', '3')
JSON-RPC, aria2 JSON-, .
XML-RPC, aria2 faultCode=1 faultString.
, -i. .
, - ( "--"), - .
JSON-RPC
{'split':'1', 'http-proxy':'http://proxy/'}
XML-RPC
<struct>
<member>
<name>split</name>
<value><string>1</string></value>
</member>
<member>
<name>http-proxy</name>
<value><string>http://proxy/</string></value>
</member>
</struct>
header index-out . ( XML-RPC ), . ,
, .
JSON-RPC
{'header':['Accept-Language: ja', 'Accept-Charset: utf-8']}
XML-RPC
<struct>
<member>
<name>header</name>
<value>
<array>
<data>
<value><string>Accept-Language: ja</string></value>
<value><string>Accept-Charset: utf-8</string></value>
</data>
</array>
</value>
</member>
</struct>
: dir header. header 2 , :
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> opts = dict(dir='/tmp',
... header=['Accept-Language: ja',
... 'Accept-Charset: utf-8'])
>>> s.aria2.addUri(['http://example.org/file'], opts)
'1'
JSON-RPC HTTP GET
JSON-RPC- HTTP GET. GET JSON-RPC HTTP (2008-1-15(RC1)).
GET :
/jsonrpc?method=METHOD_NAME&id=ID¶ms=BASE64_ENCODED_PARAMS
method id JSON- UTF-8.
, aria2.tellStatus(3) id=foo :
/jsonrpc?method=aria2.tellStatus&id=foo¶ms=WyIzIl0%3D
params - JSON- Base64-, params JSON-RPC- . , params - [3], :
['3'] --(Base64)--> WyIzIl0= --(Percent Encode)--> WyIzIl0%3D
JSON-RPC- JSONP. jsoncallback.
/jsonrpc?method=aria2.tellStatus&id=foo¶ms=WyIzIl0%3D&jsoncallback=cb
, method id . params. ,
[{'jsonrpc':'2.0', 'id':'qwer', 'method':'aria2.getVersion'},
{'jsonrpc':'2.0', 'id':'asdf', 'method':'aria2.tellActive'}]
:
/jsonrpc?params=W3sianNvbnJwYyI6ICIyLjAiLCAiaWQiOiAicXdlciIsICJtZXRob2QiOiAiYXJpYTIuZ2V0VmVyc2lvbiJ9LCB7Impzb25ycGMiOiAiMi4wIiwgImlkIjogImFzZGYiLCAibWV0aG9kIjogImFyaWEyLnRlbGxBY3RpdmUifV0%3D
XML-RPC
Ruby- http://localhost/aria2.tar.bz2 --dir=/downloads aria2c,
localhost .
#!/usr/bin/env ruby
require 'xmlrpc/client'
require 'pp'
client=XMLRPC::Client.new2("http://localhost:6800/rpc")
options={ "dir" => "/downloads" }
result=client.call("aria2.addUri", [ "http://localhost/aria2.tar.bz2" ], options)
pp result
Python, xmlrpclib( Python3.x, xmlrpc.client) aria2.
import xmlrpclib
from pprint import pprint
s = xmlrpclib.ServerProxy("http://localhost:6800/rpc")
r = s.aria2.addUri(["http://localhost/aria2.tar.bz2"], {"dir":"/downloads"})
pprint(r)
HTTP/FTP
aria2c "http://host/file.zip"
, Ctrl-C. , aria2c . URI, .
2- HTTP-
aria2c "http://host/file.zip" "http://mirror/file.zip"
, 2
aria2c -x2 -k1M "http://host/file.zip"
HTTP- FTP-
aria2c "http://host1/file.zip" "ftp://host2/file.zip"
,
aria2c -ifiles.txt -j2
-j .
-
HTTP:
aria2c --http-proxy="http://proxy:8080" "http://host/file"
aria2c --http-proxy="http://proxy:8080" --no-proxy="localhost,127.0.0.1,192.168.0.0/16" "http://host/file"
FTP:
aria2c --ftp-proxy="http://proxy:8080" "ftp://host/file"
--http-proxy, --https-proxy, --ftp-proxy, --all-proxy
--no-proxy. . .
-
aria2c --http-proxy="http://username:password@proxy:8080" "http://host/file"
aria2c --http-proxy="http://proxy:8080" --http-proxy-user="username" --http-proxy-passwd="password" "http://host/file"
Metalink
Metalink
aria2c --follow-metalink=mem "http://host/file.metalink"
, metalink-
aria2c -p --lowest-speed-limit=4000 file.metalink
, Ctrl-C. , aria2c .
metalink-
aria2c -j2 file1.metalink file2.metalink
,
aria2c --select-file=1-4,8 file.metalink
-S.
, .metalink-
aria2c --metalink-location=jp,us --metalink-version=1.1 --metalink-language=en-US file.metalink
BitTorrent
BitTorrent-
aria2c --follow-torrent=mem "http://host/file.torrent"
, torrent-
aria2c --max-upload-limit=40K file.torrent
--max-upload-limit .
, Ctrl-C. , aria2c .
, BitTorrent Magnet URI
aria2c "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C&dn=aria2"
BitTorrent Magnet URI, "&", (') (") .
2-
aria2c -j2 file1.torrent file2.torrent
, HTTP/FTP-
aria2c -Ttest.torrent "http://host1/file" "ftp://host2/file"
HTTP/FTP .
, ( " ")
aria2c --select-file=1-4,8 file.torrent
-S.
BitTorrent-, torrent-, -S. , :
idx|path/length
===+======================
1|dist/base-2.6.18.iso
|99.9MiB
---+----------------------
2|dist/driver-2.6.18.iso
|169.0MiB
---+----------------------
dist/base-2.6.18.iso /tmp/mydir/base.iso dist/driver-2.6.18.iso
/tmp/dir/driver.iso, :
aria2c --dir=/tmp --index-out=1=mydir/base.iso --index-out=2=dir/driver.iso file.torrent
aria2c --listen-port=7000-7001,8000 file.torrent
.. aria2 , .
aria2c --seed-time=120 --seed-ratio=1.0 file.torrent
, 120 1.0.
aria2c --max-upload-limit=100K file.torrent
IPv4 DHT
aria2c --enable-dht --dht-listen-port=6881 file.torrent
DHT udp-. aria2 , .
IPv6 DHT
aria2c --enable-dht6 --dht-listen-port=6881
--dht-listen-addr6=YOUR_GLOBAL_UNICAST_IPV6_ADDR --enable-async-dns6
aria2c c-ares, --enable-async-dns6 . aria2 IPv4
IPv6 DHT.
URI
URI , file.torrent "http://tracker1/announce"
"http://tracker2/announce".
aria2c --bt-exclude-tracker="*"
--bt-tracker="http://tracker1/announce,http://tracker2/announce"
file.torrent
HTTP
aria2c --load-cookies=cookies.txt "http://host/file.zip"
cookie- Firefox/Mozilla/Chromium.
,
aria2c -c -s2 "http://host/partiallydownloadedfile.zip"
SSL/TLS
aria2c --certificate=/path/to/mycert.pem --private-key=/path/to/mykey.pem https://host/file
--private-key . .
SSL/TLS, CA-
aria2c --ca-certificate=/path/to/ca-certificates.crt --check-certificate https://host/file
aria2c --max-download-limit=100K file.metalink
aria2c -V file.metalink
BitTorrent Metalink .
,
aria2c --lowest-speed-limit=10K file.metalink
URI
:
aria2c -P "http://{host1,host2,host3}/file.iso"
:
aria2c -Z -P "http://host/image[000-100].png"
-Z , URI , .
:
aria2c -Z -P "http://host/image[A-Z:2].png"
aria2c --checksum=sha-1=0192ba11326fe2298c8cb4de616f4d4140213837 http://example.org/file
URI,metalink,torrent
aria2c -j3 -Z "http://host/file1" file2.torrent file3.metalink
BitTorrent
ARC4:
aria2c --bt-min-crypto-level=arc4 --bt-require-crypto=true file.torrent
- : http://aria2.sourceforge.net/
aria2: http://sourceforge.net/apps/trac/aria2/wiki
Metalink: http://www.metalinker.org/
Metalink: http://tools.ietf.org/html/rfc5854
(C) 2006, 2011 Tatsuhiro Tsujikawa
; / GNU General Public License, Free Software
Foundation; License 2, ( ) .
, , - , . . GNU General Public License .
GNU General Public License ; , Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
, , OpenSSL , , . GNU General Public
License , OpenSSL. () , (), . , .
, .
ITriskTI <ITriskTI@gmail.com>
, , , , , e-mail.
. , , .
Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
.