aria2c.rst 135 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969
  1. aria2c(1)
  2. =========
  3. SYNOPSIS
  4. --------
  5. **aria2c** [<OPTIONS>] [<URI>|<MAGNET>|<TORRENT_FILE>|<METALINK_FILE>] ...
  6. DESCRIPTION
  7. -----------
  8. aria2 is a utility for downloading files. The supported protocols are
  9. HTTP(S), FTP, BitTorrent, and Metalink. aria2 can download a file from
  10. multiple sources/protocols and tries to utilize your maximum download
  11. bandwidth. It supports downloading a file from HTTP(S)/FTP and
  12. BitTorrent at the same time, while the data downloaded from
  13. HTTP(S)/FTP is uploaded to the BitTorrent swarm. Using Metalink's
  14. chunk checksums, aria2 automatically validates chunks of data while
  15. downloading a file like BitTorrent.
  16. OPTIONS
  17. -------
  18. Basic Options
  19. ~~~~~~~~~~~~~
  20. .. option:: -d, --dir=<DIR>
  21. The directory to store the downloaded file.
  22. .. option:: -i, --input-file=<FILE>
  23. Downloads URIs found in FILE. You can specify multiple URIs for a single
  24. entity: separate URIs on a single line using the TAB character.
  25. Reads input from stdin when ``-`` is specified.
  26. Additionally, options can be specified after each line of
  27. URI. This optional line must start with one or more white spaces and have
  28. one option per single line.
  29. The input file can use gzip compression.
  30. See `Input File`_ subsection for details.
  31. See also :option:`--deferred-input` option.
  32. .. option:: -l, --log=<LOG>
  33. The file name of the log file. If ``-`` is specified, log is written to
  34. stdout. If empty string("") is specified, log is not written to file.
  35. .. option:: -j, --max-concurrent-downloads=<N>
  36. Set maximum number of parallel downloads for every static (HTTP/FTP) URI,
  37. torrent and metalink. See also :option:`--split <-s>` option.
  38. Default: ``5``
  39. .. option:: -V, --check-integrity[=true|false]
  40. Check file integrity by validating piece hashes or a hash of entire
  41. file. This option has effect only in BitTorrent, Metalink downloads
  42. with checksums or HTTP(S)/FTP downloads with
  43. :option:`--checksum` option. If
  44. piece hashes are provided, this option can detect damaged portions
  45. of a file and re-download them. If a hash of entire file is
  46. provided, hash check is only done when file has been already
  47. download. This is determined by file length. If hash check fails,
  48. file is re-downloaded from scratch. If both piece hashes and a hash
  49. of entire file are provided, only piece hashes are used. Default:
  50. ``false``
  51. .. option:: -c, --continue[=true|false]
  52. Continue downloading a partially downloaded file.
  53. Use this option to resume a download started by a web browser or another
  54. program which downloads files sequentially from the beginning.
  55. Currently this option is only applicable to HTTP(S)/FTP downloads.
  56. .. option:: -h, --help[=<TAG>|<KEYWORD>]
  57. The help messages are classified with tags. A tag starts with
  58. ``#``. For example, type ``--help=#http`` to get the usage for the
  59. options tagged with ``#http``. If non-tag word is given, print the
  60. usage for the options whose name includes that word. Available
  61. Values: ``#basic``, ``#advanced``, ``#http``, ``#https``, ``#ftp``,
  62. ``#metalink``, ``#bittorrent``, ``#cookie``, ``#hook``, ``#file``, ``#rpc``,
  63. ``#checksum``, ``#experimental``, ``#deprecated``, ``#help``, ``#all``
  64. Default: ``#basic``
  65. HTTP/FTP Options
  66. ~~~~~~~~~~~~~~~~
  67. .. option:: --all-proxy=<PROXY>
  68. Use this proxy server for all protocols. To erase previously
  69. defined proxy, use "". You can override this setting and specify a
  70. proxy server for a particular protocol using :option:`--http-proxy`,
  71. :option:`--https-proxy` and :option:`--ftp-proxy` options. This affects all URIs.
  72. The format of PROXY is ``[http://][USER:PASSWORD@]HOST[:PORT]``.
  73. See also `ENVIRONMENT`_ section.
  74. .. note::
  75. If user and password are embedded in proxy URI and they are also
  76. specified by *--{http,https,ftp,all}-proxy-{user,passwd}* options,
  77. those appeared later have precedence. For example, you have
  78. ``http-proxy-user=myname``, ``http-proxy-passwd=mypass`` in aria2.conf and
  79. you specify ``--http-proxy="http://proxy"`` in command-line, then you get
  80. HTTP proxy ``http://proxy`` with user ``myname`` and password
  81. ``mypass``.
  82. Another example: if you specified in command-line
  83. ``--http-proxy="http://user:pass@proxy" --http-proxy-user="myname"
  84. --http-proxy-passwd="mypass"``, then you will get HTTP proxy
  85. ``http://proxy`` with user ``myname`` and password ``mypass``.
  86. One more example: if you specified in command-line ``--http-proxy-user="myname"
  87. --http-proxy-passwd="mypass" --http-proxy="http://user:pass@proxy"``,
  88. then you get HTTP proxy ``http://proxy`` with user ``user`` and password
  89. ``pass``.
  90. .. option:: --all-proxy-passwd=<PASSWD>
  91. Set password for :option:`--all-proxy` option.
  92. .. option:: --all-proxy-user=<USER>
  93. Set user for :option:`--all-proxy` option.
  94. .. option:: --checksum=<TYPE>=<DIGEST>
  95. Set checksum. TYPE is hash type. The supported hash type is listed
  96. in ``Hash Algorithms`` in ``aria2c -v``. DIGEST is hex digest. For
  97. example, setting sha-1 digest looks like this:
  98. ``sha-1=0192ba11326fe2298c8cb4de616f4d4140213838`` This option applies
  99. only to HTTP(S)/FTP downloads.
  100. .. option:: --connect-timeout=<SEC>
  101. Set the connect timeout in seconds to establish connection to
  102. HTTP/FTP/proxy server. After the connection is established, this
  103. option makes no effect and :option:`--timeout <-t>` option is used instead.
  104. Default: ``60``
  105. .. option:: --dry-run[=true|false]
  106. If ``true`` is given, aria2 just checks whether the remote file is
  107. available and doesn't download data. This option has effect on
  108. HTTP/FTP download. BitTorrent downloads are canceled if ``true`` is
  109. specified. Default: ``false``
  110. .. option:: --lowest-speed-limit=<SPEED>
  111. Close connection if download speed is lower than or equal to this
  112. value(bytes per sec).
  113. ``0`` means aria2 does not have a lowest speed limit.
  114. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  115. This option does not affect BitTorrent downloads.
  116. Default: ``0``
  117. .. option:: -x, --max-connection-per-server=<NUM>
  118. The maximum number of connections to one server for each download.
  119. Default: ``1``
  120. .. option:: --max-file-not-found=<NUM>
  121. If aria2 receives "file not found" status from the remote HTTP/FTP
  122. servers NUM times without getting a single byte, then force the
  123. download to fail. Specify ``0`` to disable this option. This options is
  124. effective only when using HTTP/FTP servers.
  125. Default: ``0``
  126. .. option:: -m, --max-tries=<N>
  127. Set number of tries. ``0`` means unlimited.
  128. See also :option:`--retry-wait`.
  129. Default: ``5``
  130. .. option:: -k, --min-split-size=<SIZE>
  131. aria2 does not split less than 2*SIZE byte range. For example,
  132. let's consider downloading 20MiB file. If SIZE is 10M, aria2 can
  133. split file into 2 range [0-10MiB) and [10MiB-20MiB) and download it
  134. using 2 sources(if :option:`--split <-s>` >= 2, of course). If SIZE is 15M,
  135. since 2*15M > 20MiB, aria2 does not split file and download it using
  136. 1 source. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  137. Possible Values: ``1M`` -``1024M`` Default: ``20M``
  138. .. option:: -n, --no-netrc[=true|false]
  139. Disables netrc support. netrc support is enabled by default.
  140. .. note::
  141. netrc file is only read at the startup if
  142. :option:`--no-netrc <-n>` is ``false``.
  143. So if :option:`--no-netrc <-n>` is ``true`` at the startup,
  144. no netrc is available throughout the session.
  145. You cannot get netrc enabled even if you send
  146. :option:`--no-netrc=false <-n>` using
  147. :func:`aria2.changeGlobalOption`.
  148. .. option:: --no-proxy=<DOMAINS>
  149. Specify comma separated hostnames, domains and network address with
  150. or without CIDR block where proxy should not be used.
  151. .. note::
  152. For network address with CIDR block, both IPv4 and IPv6 addresses work. Current
  153. implementation does not resolve hostname in URI to compare network
  154. address specified in :option:`--no-proxy`. So it is only effecive if URI has
  155. numeric IP addresses.
  156. .. option:: -o, --out=<FILE>
  157. The file name of the downloaded file. When :option:`--force-sequential <-Z>` option is used, this
  158. option is ignored.
  159. .. note::
  160. In Metalink or BitTorrent download you cannot specify file name.
  161. The file name specified here is only used when the URIs fed to aria2
  162. are done by command line without :option:`--input-file <-i>`, :option:`--force-sequential <-Z>` option. For example:
  163. .. code-block:: console
  164. $ aria2c -o myfile.zip "http://mirror1/file.zip" "http://mirror2/file.zip"
  165. .. option:: --proxy-method=<METHOD>
  166. Set the method to use in proxy request. METHOD is either ``get`` or
  167. ``tunnel``. HTTPS downloads always use ``tunnel`` regardless of this
  168. option.
  169. Default: ``get``
  170. .. option:: -R, --remote-time[=true|false]
  171. Retrieve timestamp of the remote file from the remote HTTP/FTP
  172. server and if it is available, apply it to the local file.
  173. Default: ``false``
  174. .. option:: --reuse-uri[=true|false]
  175. Reuse already used URIs if no unused URIs are left.
  176. Default: ``true``
  177. .. option:: --retry-wait=<SEC>
  178. Set the seconds to wait between retries. With SEC > 0, aria2 will
  179. retry download when the HTTP server returns 503 response. Default:
  180. ``0``
  181. .. option:: --server-stat-of=<FILE>
  182. Specify the filename to which performance profile of the servers is
  183. saved. You can load saved data using :option:`--server-stat-if` option. See
  184. `Server Performance Profile`_
  185. subsection below for file format.
  186. .. option:: --server-stat-if=<FILE>
  187. Specify the filename to load performance profile of the servers. The
  188. loaded data will be used in some URI selector such as ``feedback``.
  189. See also :option:`--uri-selector` option. See
  190. `Server Performance Profile`_
  191. subsection below for file format.
  192. .. option:: --server-stat-timeout=<SEC>
  193. Specifies timeout in seconds to invalidate performance profile of
  194. the servers since the last contact to them.
  195. Default: ``86400`` (24hours)
  196. .. option:: -s, --split=<N>
  197. Download a file using N connections. If more than N URIs are given,
  198. first N URIs are used and remaining URIs are used for backup. If
  199. less than N URIs are given, those URIs are used more than once so
  200. that N connections total are made simultaneously. The number of
  201. connections to the same host is restricted by
  202. :option:`--max-connection-per-server <-x>` option.
  203. See also :option:`--min-split-size <-k>` option.
  204. Default: ``5``
  205. .. note::
  206. Some Metalinks regulate the number of servers to connect. aria2
  207. strictly respects them. This means that if Metalink defines the
  208. maxconnections attribute lower than N, then aria2 uses the
  209. value of maxconnections attribute instead of N.
  210. .. option:: --stream-piece-selector=<SELECTOR>
  211. Specify piece selection algorithm used in HTTP/FTP download. Piece
  212. means fixed length segment which is downloaded in parallel in
  213. segmented download. If ``default`` is given, aria2 selects piece so
  214. that it reduces the number of establishing connection. This is
  215. reasonable default behaviour because establishing connection is an
  216. expensive operation. If ``inorder`` is given, aria2 selects piece
  217. which has minimum index. Index=0 means first of the file. This will
  218. be useful to view movie while downloading it.
  219. :option:`--enable-http-pipelining` option may
  220. be useful to reduce reconnection overhead. Please note that aria2
  221. honors
  222. :option:`--min-split-size <-k>` option,
  223. so it will be necessary to specify a reasonable value to
  224. :option:`--min-split-size <-k>` option.
  225. If ``geom`` is given, at the beginning aria2 selects piece which has
  226. minimum index like ``inorder``, but it exponentially increasingly
  227. keeps space from previously selected piece. This will reduce the
  228. number of establishing connection and at the same time it will
  229. download the beginning part of the file first. This will be useful
  230. to view movie while downloading it.
  231. Default: ``default``
  232. .. option:: -t, --timeout=<SEC>
  233. Set timeout in seconds.
  234. Default: ``60``
  235. .. option:: --uri-selector=<SELECTOR>
  236. Specify URI selection algorithm. The possible values are ``inorder``,
  237. ``feedback`` and ``adaptive``. If ``inorder`` is given, URI is tried in
  238. the order appeared in the URI list. If ``feedback`` is given, aria2
  239. uses download speed observed in the previous downloads and choose
  240. fastest server in the URI list. This also effectively skips dead
  241. mirrors. The observed download speed is a part of performance
  242. profile of servers mentioned in :option:`--server-stat-of` and
  243. :option:`--server-stat-if` options. If ``adaptive`` is given, selects one of
  244. the best mirrors for the first and reserved connections. For
  245. supplementary ones, it returns mirrors which has not been tested
  246. yet, and if each of them has already been tested, returns mirrors
  247. which has to be tested again. Otherwise, it doesn't select anymore
  248. mirrors. Like ``feedback``, it uses a performance profile of servers.
  249. Default: ``feedback``
  250. HTTP Specific Options
  251. ~~~~~~~~~~~~~~~~~~~~~
  252. .. option:: --ca-certificate=<FILE>
  253. Use the certificate authorities in FILE to verify the peers.
  254. The certificate file must be in PEM format and can contain multiple CA
  255. certificates.
  256. Use :option:`--check-certificate` option to enable verification.
  257. .. note::
  258. If you build with OpenSSL or the recent version of GnuTLS which
  259. has ``gnutls_certificate_set_x509_system_trust()`` function and
  260. the library is properly configured to locate the system-wide CA
  261. certificates store, aria2 will automatically load those
  262. certificates at the startup.
  263. .. note::
  264. *WinTLS* and *AppleTLS* do not support this option. Instead you will
  265. have to import the certificate into the OS trust store.
  266. .. option:: --certificate=<FILE>
  267. Use the client certificate in FILE. The certificate must be
  268. either in PKCS12 (.p12, .pfx) or in PEM format.
  269. PKCS12 files must contain the certificate, a key and optionally a chain
  270. of additional certificates. Only PKCS12 files with a blank import password
  271. can be opened!
  272. When using PEM, you have to specify the private key via :option:`--private-key`
  273. as well.
  274. .. note::
  275. *WinTLS* does not support PEM files at the moment. Users have to use PKCS12
  276. files.
  277. .. note::
  278. *AppleTLS* users should use the Keychain Access utility to import the client
  279. certificate and get the SHA-1 fingerprint from the Information dialog
  280. corresponding to that certificate.
  281. To start aria2c use `--certificate=<SHA-1>`.
  282. Alternatively PKCS12 files are also supported. PEM files, however, are not
  283. supported.
  284. .. option:: --check-certificate[=true|false]
  285. Verify the peer using certificates specified in :option:`--ca-certificate` option.
  286. Default: ``true``
  287. .. option:: --http-accept-gzip[=true|false]
  288. Send ``Accept: deflate, gzip`` request header and inflate response if
  289. remote server responds with ``Content-Encoding: gzip`` or
  290. ``Content-Encoding: deflate``. Default: ``false``
  291. .. note::
  292. Some server responds with ``Content-Encoding: gzip`` for files which
  293. itself is gzipped file. aria2 inflates them anyway because of the
  294. response header.
  295. .. option:: --http-auth-challenge[=true|false]
  296. Send HTTP authorization header only when it is requested by the
  297. server. If ``false`` is set, then authorization header is always sent
  298. to the server. There is an exception: if username and password are
  299. embedded in URI, authorization header is always sent to the server
  300. regardless of this option. Default: ``false``
  301. .. option:: --http-no-cache[=true|false]
  302. Send ``Cache-Control: no-cache`` and ``Pragma: no-cache`` header to avoid
  303. cached content. If ``false`` is given, these headers are not sent
  304. and you can add Cache-Control header with a directive you like
  305. using :option:`--header` option. Default: ``false``
  306. .. option:: --http-user=<USER>
  307. Set HTTP user. This affects all URIs.
  308. .. option:: --http-passwd=<PASSWD>
  309. Set HTTP password. This affects all URIs.
  310. .. option:: --http-proxy=<PROXY>
  311. Use this proxy server for HTTP. To erase previously defined proxy,
  312. use "". See also :option:`--all-proxy` option. This affects all URIs. The
  313. format of PROXY is ``[http://][USER:PASSWORD@]HOST[:PORT]``
  314. .. option:: --http-proxy-passwd=<PASSWD>
  315. Set password for :option:`--http-proxy` option.
  316. .. option:: --http-proxy-user=<USER>
  317. Set user for :option:`--http-proxy` option.
  318. .. option:: --https-proxy=<PROXY>
  319. Use this proxy server for HTTPS. To erase previously defined proxy,
  320. use "". See also :option:`--all-proxy` option. This affects all URIs. The
  321. format of PROXY is ``[http://][USER:PASSWORD@]HOST[:PORT]``
  322. .. option:: --https-proxy-passwd=<PASSWD>
  323. Set password for :option:`--https-proxy` option.
  324. .. option:: --https-proxy-user=<USER>
  325. Set user for :option:`--https-proxy` option.
  326. .. option:: --private-key=<FILE>
  327. Use the private key in FILE.
  328. The private key must be decrypted and in PEM format.
  329. The behavior when encrypted one is given is undefined.
  330. See also :option:`--certificate` option.
  331. .. option:: --referer=<REFERER>
  332. Set Referer. This affects all URIs. If ``*`` is given, each request
  333. URI is used as a referer. This may be useful when used with
  334. :option:`--parameterized-uri <-P>` option.
  335. .. option:: --enable-http-keep-alive[=true|false]
  336. Enable HTTP/1.1 persistent connection.
  337. Default: ``true``
  338. .. option:: --enable-http-pipelining[=true|false]
  339. Enable HTTP/1.1 pipelining.
  340. Default: ``false``
  341. .. note::
  342. In performance perspective, there is usually no advantage to enable
  343. this option.
  344. .. option:: --header=<HEADER>
  345. Append HEADER to HTTP request header.
  346. You can use this option repeatedly to specify more than one header:
  347. .. code-block:: console
  348. $ aria2c --header="X-A: b78" --header="X-B: 9J1" "http://host/file"
  349. .. option:: --load-cookies=<FILE>
  350. Load Cookies from FILE using the Firefox3 format (SQLite3),
  351. Chromium/Google Chrome (SQLite3) and the
  352. Mozilla/Firefox(1.x/2.x)/Netscape format.
  353. .. note::
  354. If aria2 is built without libsqlite3, then it doesn't support Firefox3
  355. and Chromium/Google Chrome cookie format.
  356. .. option:: --save-cookies=<FILE>
  357. Save Cookies to FILE in Mozilla/Firefox(1.x/2.x)/ Netscape
  358. format. If FILE already exists, it is overwritten. Session Cookies
  359. are also saved and their expiry values are treated as 0. Possible
  360. Values: ``/path/to/file``
  361. .. option:: --use-head[=true|false]
  362. Use HEAD method for the first request to the HTTP server.
  363. Default: ``false``
  364. .. option:: -U, --user-agent=<USER_AGENT>
  365. Set user agent for HTTP(S) downloads.
  366. Default: ``aria2/$VERSION``, $VERSION is replaced by package version.
  367. FTP Specific Options
  368. ~~~~~~~~~~~~~~~~~~~~
  369. .. option:: --ftp-user=<USER>
  370. Set FTP user. This affects all URIs.
  371. Default: ``anonymous``
  372. .. option:: --ftp-passwd=<PASSWD>
  373. Set FTP password. This affects all URIs.
  374. If user name is embedded but password is missing in URI, aria2 tries
  375. to resolve password using .netrc. If password is found in .netrc,
  376. then use it as password. If not, use the password specified in this
  377. option.
  378. Default: ``ARIA2USER@``
  379. .. option:: -p, --ftp-pasv[=true|false]
  380. Use the passive mode in FTP.
  381. If ``false`` is given, the active mode will be used.
  382. Default: ``true``
  383. .. option:: --ftp-proxy=<PROXY>
  384. Use this proxy server for FTP. To erase previously defined proxy,
  385. use "". See also :option:`--all-proxy` option. This affects all URIs. The
  386. format of PROXY is ``[http://][USER:PASSWORD@]HOST[:PORT]``
  387. .. option:: --ftp-proxy-passwd=<PASSWD>
  388. Set password for :option:`--ftp-proxy` option.
  389. .. option:: --ftp-proxy-user=<USER>
  390. Set user for :option:`--ftp-proxy` option.
  391. .. option:: --ftp-type=<TYPE>
  392. Set FTP transfer type. TYPE is either ``binary`` or ``ascii``.
  393. Default: ``binary``
  394. .. option:: --ftp-reuse-connection[=true|false]
  395. Reuse connection in FTP.
  396. Default: ``true``
  397. BitTorrent/Metalink Options
  398. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  399. .. option:: --select-file=<INDEX>...
  400. Set file to download by specifying its index.
  401. You can find the file index using the :option:`--show-files <-S>` option.
  402. Multiple indexes can be specified by using ``,``, for example: ``3,6``.
  403. You can also use ``-`` to specify a range: ``1-5``.
  404. ``,`` and ``-`` can be used together: ``1-5,8,9``.
  405. When used with the -M option, index may vary depending on the query
  406. (see *--metalink-\** options).
  407. .. note::
  408. In multi file torrent, the adjacent files specified by this option may
  409. also be downloaded. This is by design, not a bug.
  410. A single piece may include several files or part of files, and aria2
  411. writes the piece to the appropriate files.
  412. .. option:: -S, --show-files[=true|false]
  413. Print file listing of ".torrent", ".meta4" and ".metalink" file and exit.
  414. In case of ".torrent" file, additional information
  415. (infohash, piece length, etc) is also printed.
  416. BitTorrent Specific Options
  417. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  418. .. option:: --bt-enable-lpd[=true|false]
  419. Enable Local Peer Discovery. If a private flag is set in a torrent,
  420. aria2 doesn't use this feature for that download even if ``true`` is
  421. given. Default: ``false``
  422. .. option:: --bt-exclude-tracker=<URI>[,...]
  423. Comma separated list of BitTorrent tracker's announce URI to
  424. remove. You can use special value ``*`` which matches all URIs, thus
  425. removes all announce URIs. When specifying ``*`` in shell
  426. command-line, don't forget to escape or quote it. See also
  427. :option:`--bt-tracker` option.
  428. .. option:: --bt-external-ip=<IPADDRESS>
  429. Specify the external IP address to report to a BitTorrent
  430. tracker. Although this function is named ``external``, it can accept
  431. any kind of IP addresses. IPADDRESS must be a numeric IP address.
  432. .. option:: --bt-hash-check-seed[=true|false]
  433. If ``true`` is given, after hash check using :option:`--check-integrity <-V>` option and
  434. file is complete, continue to seed file. If you want to check file
  435. and download it only when it is damaged or incomplete, set this
  436. option to ``false``. This option has effect only on BitTorrent download.
  437. Default: ``true``
  438. .. option:: --bt-lpd-interface=<INTERFACE>
  439. Use given interface for Local Peer Discovery. If this option is not
  440. specified, the default interface is chosen. You can specify
  441. interface name and IP address. Possible Values: interface, IP
  442. addres
  443. .. option:: --bt-max-open-files=<NUM>
  444. Specify maximum number of files to open in multi-file
  445. BitTorrent/Metalink download globally.
  446. Default: ``100``
  447. .. option:: --bt-max-peers=<NUM>
  448. Specify the maximum number of peers per torrent. ``0`` means
  449. unlimited. See also :option:`--bt-request-peer-speed-limit` option.
  450. Default: ``55``
  451. .. option:: --bt-metadata-only[=true|false]
  452. Download metadata only. The file(s) described in metadata will not
  453. be downloaded. This option has effect only when BitTorrent Magnet
  454. URI is used. See also :option:`--bt-save-metadata` option. Default: ``false``
  455. .. option:: --bt-min-crypto-level=plain|arc4
  456. Set minimum level of encryption method.
  457. If several encryption methods are provided by a peer, aria2 chooses the lowest
  458. one which satisfies the given level.
  459. Default: ``plain``
  460. .. option:: --bt-prioritize-piece=head[=<SIZE>],tail[=<SIZE>]
  461. Try to download first and last pieces of each file first. This is
  462. useful for previewing files. The argument can contain 2 keywords:
  463. ``head`` and ``tail``. To include both keywords, they must be separated
  464. by comma. These keywords can take one parameter, SIZE. For example,
  465. if ``head=<SIZE>`` is specified, pieces in the range of first SIZE bytes
  466. of each file get higher priority. ``tail=<SIZE>`` means the range of
  467. last SIZE bytes of each file. SIZE can include ``K`` or ``M`` (1K = 1024,
  468. 1M = 1024K). If SIZE is omitted, SIZE=1M is used.
  469. .. option:: --bt-remove-unselected-file[=true|false]
  470. Removes the unselected files when download is completed in
  471. BitTorrent. To select files, use
  472. :option:`--select-file` option. If it is
  473. not used, all files are assumed to be selected. Please use this
  474. option with care because it will actually remove files from your
  475. disk.
  476. Default: ``false``
  477. .. option:: --bt-require-crypto[=true|false]
  478. If true is given, aria2 doesn't accept and establish connection with legacy
  479. BitTorrent handshake(\19BitTorrent protocol).
  480. Thus aria2 always uses Obfuscation handshake.
  481. Default: ``false``
  482. .. option:: --bt-request-peer-speed-limit=<SPEED>
  483. If the whole download speed of every torrent is lower than SPEED,
  484. aria2 temporarily increases the number of peers to try for more
  485. download speed. Configuring this option with your preferred download
  486. speed can increase your download speed in some cases.
  487. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  488. Default: ``50K``
  489. .. option:: --bt-save-metadata[=true|false]
  490. Save metadata as ".torrent" file. This option has effect only when
  491. BitTorrent Magnet URI is used. The filename is hex encoded info
  492. hash with suffix ".torrent". The directory to be saved is the same
  493. directory where download file is saved. If the same file already
  494. exists, metadata is not saved. See also :option:`--bt-metadata-only`
  495. option. Default: ``false``
  496. .. option:: --bt-seed-unverified[=true|false]
  497. Seed previously downloaded files without verifying piece hashes.
  498. Default: ``false``
  499. .. option:: --bt-stop-timeout=<SEC>
  500. Stop BitTorrent download if download speed is 0 in consecutive SEC
  501. seconds. If ``0`` is given, this feature is disabled. Default: ``0``
  502. .. option:: --bt-tracker=<URI>[,...]
  503. Comma separated list of additional BitTorrent tracker's announce
  504. URI. These URIs are not affected by :option:`--bt-exclude-tracker` option
  505. because they are added after URIs in :option:`--bt-exclude-tracker` option are
  506. removed.
  507. .. option:: --bt-tracker-connect-timeout=<SEC>
  508. Set the connect timeout in seconds to establish connection to
  509. tracker. After the connection is established, this option makes no
  510. effect and :option:`--bt-tracker-timeout` option is used instead. Default:
  511. ``60``
  512. .. option:: --bt-tracker-interval=<SEC>
  513. Set the interval in seconds between tracker requests. This
  514. completely overrides interval value and aria2 just uses this value
  515. and ignores the min interval and interval value in the response of
  516. tracker. If ``0`` is set, aria2 determines interval based on the
  517. response of tracker and the download progress. Default: ``0``
  518. .. option:: --bt-tracker-timeout=<SEC>
  519. Set timeout in seconds. Default: ``60``
  520. .. option:: --dht-entry-point=<HOST>:<PORT>
  521. Set host and port as an entry point to IPv4 DHT network.
  522. .. option:: --dht-entry-point6=<HOST>:<PORT>
  523. Set host and port as an entry point to IPv6 DHT network.
  524. .. option:: --dht-file-path=<PATH>
  525. Change the IPv4 DHT routing table file to PATH.
  526. Default: ``$HOME/.aria2/dht.dat``
  527. .. option:: --dht-file-path6=<PATH>
  528. Change the IPv6 DHT routing table file to PATH.
  529. Default: ``$HOME/.aria2/dht6.dat``
  530. .. option:: --dht-listen-addr6=<ADDR>
  531. Specify address to bind socket for IPv6 DHT. It should be a global
  532. unicast IPv6 address of the host.
  533. .. option:: --dht-listen-port=<PORT>...
  534. Set UDP listening port used by DHT(IPv4, IPv6) and UDP tracker.
  535. Multiple ports can be specified by using ``,``, for example:
  536. ``6881,6885``. You can also use ``-`` to specify a range:
  537. ``6881-6999``. ``,`` and ``-`` can be used together.
  538. Default: ``6881-6999``
  539. .. note::
  540. Make sure that the specified ports are open for incoming UDP traffic.
  541. .. option:: --dht-message-timeout=<SEC>
  542. Set timeout in seconds. Default: ``10``
  543. .. option:: --enable-dht[=true|false]
  544. Enable IPv4 DHT functionality. It also enables UDP tracker
  545. support. If a private flag is set in a torrent, aria2 doesn't use
  546. DHT for that download even if ``true`` is given. Default: ``true``
  547. .. option:: --enable-dht6[=true|false]
  548. Enable IPv6 DHT functionality. If a private flag is set in a
  549. torrent, aria2 doesn't use DHT for that download even if ``true`` is
  550. given. Use :option:`--dht-listen-port` option to specify port number to
  551. listen on. See also :option:`--dht-listen-addr6` option.
  552. .. option:: --enable-peer-exchange[=true|false]
  553. Enable Peer Exchange extension. If a private flag is set in a torrent, this
  554. feature is disabled for that download even if ``true`` is given.
  555. Default: ``true``
  556. .. option:: --follow-torrent=true|false|mem
  557. If ``true`` or ``mem`` is specified, when a file whose suffix is ``.torrent`` or content
  558. type is ``application/x-bittorrent`` is downloaded, aria2 parses it as a torrent
  559. file and downloads files mentioned in it.
  560. If ``mem`` is specified, a torrent file is not written to the disk, but is just
  561. kept in memory.
  562. If ``false`` is specified, the ``.torrent`` file is downloaded to the disk, but
  563. is not parsed as a torrent and its contents are not downloaded.
  564. Default: ``true``
  565. .. option:: -O, --index-out=<INDEX>=<PATH>
  566. Set file path for file with index=INDEX. You can find the file index
  567. using the :option:`--show-files <-S>` option. PATH is a relative path to the
  568. path specified in :option:`--dir <-d>` option. You can use this option multiple
  569. times. Using this option, you can specify the output filenames of
  570. BitTorrent downloads.
  571. .. option:: --listen-port=<PORT>...
  572. Set TCP port number for BitTorrent downloads.
  573. Multiple ports can be specified by using ``,``, for example: ``6881,6885``.
  574. You can also use ``-`` to specify a range: ``6881-6999``.
  575. ``,`` and ``-`` can be used together: ``6881-6889,6999``.
  576. Default: ``6881-6999``
  577. .. note::
  578. Make sure that the specified ports are open for incoming TCP traffic.
  579. .. option:: --max-overall-upload-limit=<SPEED>
  580. Set max overall upload speed in bytes/sec.
  581. ``0`` means unrestricted.
  582. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  583. To limit the upload speed per torrent, use :option:`--max-upload-limit <-u>` option.
  584. Default: ``0``
  585. .. option:: -u, --max-upload-limit=<SPEED>
  586. Set max upload speed per each torrent in bytes/sec.
  587. ``0`` means unrestricted.
  588. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  589. To limit the overall upload speed, use :option:`--max-overall-upload-limit` option.
  590. Default: ``0``
  591. .. option:: --peer-id-prefix=<PEER_ID_PREFIX>
  592. Specify the prefix of peer ID. The peer ID in
  593. BitTorrent is 20 byte length. If more than 20
  594. bytes are specified, only first 20 bytes are
  595. used. If less than 20 bytes are specified, random
  596. byte data are added to make its length 20 bytes.
  597. Default: ``aria2/$VERSION-``, $VERSION is replaced by package version.
  598. .. option:: --seed-ratio=<RATIO>
  599. Specify share ratio. Seed completed torrents until share ratio reaches
  600. RATIO.
  601. You are strongly encouraged to specify equals or more than ``1.0`` here.
  602. Specify ``0.0`` if you intend to do seeding regardless of share ratio.
  603. If :option:`--seed-time` option is specified along with this option, seeding ends when
  604. at least one of the conditions is satisfied.
  605. Default: ``1.0``
  606. .. option:: --seed-time=<MINUTES>
  607. Specify seeding time in minutes. Also see the :option:`--seed-ratio` option.
  608. .. note::
  609. Specifying :option:`--seed-time=0 <--seed-time>` disables seeding after download completed.
  610. .. option:: -T, --torrent-file=<TORRENT_FILE>
  611. The path to the ".torrent" file. You are not required to use this
  612. option because you can specify ".torrent" files without :option:`--torrent-file <-T>`.
  613. Metalink Specific Options
  614. ~~~~~~~~~~~~~~~~~~~~~~~~~
  615. .. option:: --follow-metalink=true|false|mem
  616. If ``true`` or ``mem`` is specified, when a file whose suffix is ``.meta4`` or ``.metalink`` or content
  617. type of ``application/metalink4+xml`` or ``application/metalink+xml`` is downloaded, aria2 parses it as a metalink
  618. file and downloads files mentioned in it.
  619. If ``mem`` is specified, a metalink file is not written to the disk, but is just
  620. kept in memory.
  621. If ``false`` is specified, the ``.metalink`` file is downloaded to
  622. the disk, but is not parsed as a metalink file and its contents are not
  623. downloaded.
  624. Default: ``true``
  625. .. option:: --metalink-base-uri=<URI>
  626. Specify base URI to resolve relative URI in metalink:url and
  627. metalink:metaurl element in a metalink file stored in local disk. If
  628. URI points to a directory, URI must end with ``/``.
  629. .. option:: -M, --metalink-file=<METALINK_FILE>
  630. The file path to ".meta4" and ".metalink" file. Reads input from stdin when ``-`` is
  631. specified. You are not required to use this option because you can
  632. specify ".metalink" files without :option:`--metalink-file <-M>`.
  633. .. option:: --metalink-language=<LANGUAGE>
  634. The language of the file to download.
  635. .. option:: --metalink-location=<LOCATION>[,...]
  636. The location of the preferred server.
  637. A comma-delimited list of locations is acceptable, for example, ``jp,us``.
  638. .. option:: --metalink-os=<OS>
  639. The operating system of the file to download.
  640. .. option:: --metalink-version=<VERSION>
  641. The version of the file to download.
  642. .. option:: --metalink-preferred-protocol=<PROTO>
  643. Specify preferred protocol.
  644. The possible values are ``http``, ``https``, ``ftp`` and ``none``.
  645. Specify ``none`` to disable this feature.
  646. Default: ``none``
  647. .. option:: --metalink-enable-unique-protocol[=true|false]
  648. If ``true`` is given and several protocols are available for a mirror in a
  649. metalink file, aria2 uses one of them.
  650. Use :option:`--metalink-preferred-protocol` option to specify the preference of
  651. protocol.
  652. Default: ``true``
  653. RPC Options
  654. ~~~~~~~~~~~
  655. .. option:: --enable-rpc[=true|false]
  656. Enable JSON-RPC/XML-RPC server. It is strongly recommended to set username
  657. and password using :option:`--rpc-user` and :option:`--rpc-passwd`
  658. option. See also :option:`--rpc-listen-port` option. Default: ``false``
  659. .. option:: --pause[=true|false]
  660. Pause download after added. This option is effective only when
  661. :option:`--enable-rpc=true <--enable-rpc>` is given.
  662. Default: ``false``
  663. .. option:: --rpc-allow-origin-all[=true|false]
  664. Add Access-Control-Allow-Origin header field with value ``*`` to the
  665. RPC response.
  666. Default: ``false``
  667. .. option:: --rpc-certificate=<FILE>
  668. Use the certificate in FILE for RPC server. The certificate must be
  669. either in PKCS12 (.p12, .pfx) or in PEM format.
  670. PKCS12 files must contain the certificate, a key and optionally a chain
  671. of additional certificates. Only PKCS12 files with a blank import password
  672. can be opened!
  673. When using PEM, you have to specify the private key via :option:`--rpc-private-key`
  674. as well. Use :option:`--rpc-secure` option to enable encryption.
  675. .. note::
  676. *WinTLS* does not support PEM files at the moment. Users have to use PKCS12
  677. files.
  678. .. note::
  679. *AppleTLS* users should use the Keychain Access utility to first generate a
  680. self-signed SSL-Server certificate, e.g. using the wizard, and get the
  681. SHA-1 fingerprint from the Information dialog corresponding to that new
  682. certificate.
  683. To start aria2c with :option:`--rpc-secure` use
  684. `--rpc-certificate=<SHA-1>`.
  685. Alternatively PKCS12 files are also supported. PEM files, however, are not
  686. supported.
  687. .. option:: --rpc-listen-all[=true|false]
  688. Listen incoming JSON-RPC/XML-RPC requests on all network interfaces. If false
  689. is given, listen only on local loopback interface. Default: ``false``
  690. .. option:: --rpc-listen-port=<PORT>
  691. Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible
  692. Values: ``1024`` -``65535`` Default: ``6800``
  693. .. option:: --rpc-max-request-size=<SIZE>
  694. Set max size of JSON-RPC/XML-RPC request. If aria2 detects the request is
  695. more than SIZE bytes, it drops connection. Default: ``2M``
  696. .. option:: --rpc-passwd=<PASSWD>
  697. Set JSON-RPC/XML-RPC password.
  698. .. option:: --rpc-private-key=<FILE>
  699. Use the private key in FILE for RPC server. The private key must be
  700. decrypted and in PEM format. Use :option:`--rpc-secure` option to
  701. enable encryption. See also :option:`--rpc-certificate` option.
  702. .. option:: --rpc-save-upload-metadata[=true|false]
  703. Save the uploaded torrent or metalink metadata in the directory
  704. specified by :option:`--dir` option. The filename consists of SHA-1
  705. hash hex string of metadata plus extension. For torrent, the
  706. extension is '.torrent'. For metalink, it is '.meta4'. If false is
  707. given to this option, the downloads added by
  708. :func:`aria2.addTorrent` or :func:`aria2.addMetalink` will not be
  709. saved by :option:`--save-session` option. Default: ``false``
  710. .. option:: --rpc-secure[=true|false]
  711. RPC transport will be encrypted by SSL/TLS. The RPC clients must
  712. use https scheme to access the server. For WebSocket client, use wss
  713. scheme. Use :option:`--rpc-certificate` and
  714. :option:`--rpc-private-key` options to specify the server
  715. certificate and private key.
  716. .. option:: --rpc-user=<USER>
  717. Set JSON-RPC/XML-RPC user.
  718. Advanced Options
  719. ~~~~~~~~~~~~~~~~
  720. .. option:: --allow-overwrite[=true|false]
  721. Restart download from scratch if the corresponding control file
  722. doesn't exist. See also :option:`--auto-file-renaming` option. Default:
  723. ``false``
  724. .. option:: --allow-piece-length-change[=true|false]
  725. If false is given, aria2 aborts download when a piece length is different
  726. from one in a control file.
  727. If true is given, you can proceed but some download progress will be lost.
  728. Default: ``false``
  729. .. option:: --always-resume[=true|false]
  730. Always resume download. If ``true`` is given, aria2 always tries to
  731. resume download and if resume is not possible, aborts download. If
  732. ``false`` is given, when all given URIs do not support resume or aria2
  733. encounters ``N`` URIs which does not support resume (``N`` is the value
  734. specified using :option:`--max-resume-failure-tries` option), aria2
  735. downloads file from scratch. See :option:`--max-resume-failure-tries`
  736. option. Default: ``true``
  737. .. option:: --async-dns[=true|false]
  738. Enable asynchronous DNS.
  739. Default: ``true``
  740. .. option:: --async-dns-server=<IPADDRESS>[,...]
  741. Comma separated list of DNS server address used in asynchronous DNS
  742. resolver. Usually asynchronous DNS resolver reads DNS server
  743. addresses from ``/etc/resolv.conf``. When this option is used, it uses
  744. DNS servers specified in this option instead of ones in
  745. ``/etc/resolv.conf``. You can specify both IPv4 and IPv6 address. This
  746. option is useful when the system does not have ``/etc/resolv.conf`` and
  747. user does not have the permission to create it.
  748. .. option:: --auto-file-renaming[=true|false]
  749. Rename file name if the same file already exists.
  750. This option works only in HTTP(S)/FTP download.
  751. The new file name has a dot and a number(1..9999) appended.
  752. Default: ``true``
  753. .. option:: --auto-save-interval=<SEC>
  754. Save a control file(\*.aria2) every SEC seconds.
  755. If ``0`` is given, a control file is not saved during download. aria2 saves a
  756. control file when it stops regardless of the value.
  757. The possible values are between ``0`` to ``600``.
  758. Default: ``60``
  759. .. option:: --conditional-get[=true|false]
  760. Download file only when the local file is older than remote
  761. file. This function only works with HTTP(S) downloads only. It does
  762. not work if file size is specified in Metalink. It also ignores
  763. Content-Disposition header. If a control file exists, this option
  764. will be ignored. This function uses If-Modified-Since header to get
  765. only newer file conditionally. When getting modification time of
  766. local file, it uses user supplied filename(see :option:`--out <-o>` option) or
  767. filename part in URI if :option:`--out <-o>` is not specified.
  768. To overwrite existing file, :option:`--allow-overwrite` is required.
  769. Default: ``false``
  770. .. option:: --conf-path=<PATH>
  771. Change the configuration file path to PATH.
  772. Default: ``$HOME/.aria2/aria2.conf``
  773. .. option:: --console-log-level=<LEVEL>
  774. Set log level to output to console. LEVEL is either ``debug``,
  775. ``info``, ``notice``, ``warn`` or ``error``. Default: ``notice``
  776. .. option:: -D, --daemon[=true|false]
  777. Run as daemon. The current working directory will be changed to ``/``
  778. and standard input, standard output and standard error will be
  779. redirected to ``/dev/null``. Default: ``false``
  780. .. option:: --deferred-input[=true|false]
  781. If ``true`` is given, aria2 does not read all URIs and options from file
  782. specified by :option:`--input-file <-i>` option at startup,
  783. but it reads one by one when it
  784. needs later. This may reduce memory usage if input file contains a
  785. lot of URIs to download. If ``false`` is given, aria2 reads all URIs
  786. and options at startup.
  787. Default: ``false``
  788. .. option:: --disable-ipv6[=true|false]
  789. Disable IPv6. This is useful if you have to use broken DNS and want
  790. to avoid terribly slow AAAA record lookup. Default: ``false``
  791. .. option:: --disk-cache=<SIZE>
  792. Enable disk cache. If SIZE is ``0``, the disk cache is
  793. disabled. This feature caches the downloaded data in memory, which
  794. grows to at most SIZE bytes. The cache storage is created for aria2
  795. instance and shared by all downloads. The one advantage of the disk
  796. cache is reduce the disk I/O because the data are written in larger
  797. unit and it is reordered by the offset of the file. If hash
  798. checking is involved and the data are cached in memory, we don't
  799. need to read them from the disk. SIZE can include ``K`` or ``M``
  800. (1K = 1024, 1M = 1024K). Default: ``16M``
  801. .. option:: --download-result=<OPT>
  802. This option changes the way ``Download Results`` is formatted. If OPT
  803. is ``default``, print GID, status, average download speed and
  804. path/URI. If multiple files are involved, path/URI of first
  805. requested file is printed and remaining ones are omitted. If OPT is
  806. ``full``, print GID, status, average download speed, percentage of
  807. progress and path/URI. The percentage of progress and path/URI are
  808. printed for each requested file in each row.
  809. Default: ``default``
  810. .. option:: --enable-mmap[=true|false]
  811. Map files into memory. This option may not work if the file space
  812. is not pre-allocated. See :option:`--file-allocation`.
  813. Default: ``false``
  814. .. option:: --event-poll=<POLL>
  815. Specify the method for polling events. The possible values are
  816. ``epoll``, ``kqueue``, ``port``, ``poll`` and ``select``. For each ``epoll``,
  817. ``kqueue``, ``port`` and ``poll``, it is available if system supports it.
  818. ``epoll`` is available on recent Linux. ``kqueue`` is available on
  819. various \*BSD systems including Mac OS X. ``port`` is available on Open
  820. Solaris. The default value may vary depending on the system you use.
  821. .. option:: --file-allocation=<METHOD>
  822. Specify file allocation method.
  823. ``none`` doesn't pre-allocate file space. ``prealloc`` pre-allocates file space
  824. before download begins. This may take some time depending on the size of the
  825. file.
  826. If you are using newer file systems such as ext4
  827. (with extents support), btrfs, xfs or NTFS(MinGW build only), ``falloc`` is
  828. your best choice. It allocates large(few GiB)
  829. files almost instantly. Don't use ``falloc`` with
  830. legacy file systems such as ext3 and FAT32 because it takes
  831. almost same time as ``prealloc`` and it blocks aria2
  832. entirely until allocation finishes. ``falloc`` may
  833. not be available if your system doesn't have
  834. :manpage:`posix_fallocate(3)` function.
  835. ``trunc`` uses :manpage:`ftruncate(2)` system call or
  836. platform-specific counterpart to truncate a file to a specified
  837. length.
  838. Possible Values: ``none``, ``prealloc``, ``trunc``, ``falloc``
  839. Default: ``prealloc``
  840. .. option:: --force-save[=true|false]
  841. Save download with :option:`--save-session <--save-session>` option
  842. even if the download is completed or removed. This option also saves
  843. control file in that situations. This may be useful to save
  844. BitTorrent seeding which is recognized as completed state.
  845. Default: ``false``
  846. .. option:: --gid=<GID>
  847. Set GID manually. aria2 identifies each download by the ID called
  848. GID. The GID must be hex string of 16 characters, thus [0-9a-zA-Z]
  849. are allowed and leading zeros must not be stripped. The GID all 0 is
  850. reserved and must not be used. The GID must be unique, otherwise
  851. error is reported and the download is not added. This option is
  852. useful when restoring the sessions saved using
  853. :option:`--save-session <--save-session>` option. If this option is
  854. not used, new GID is generated by aria2.
  855. .. option:: --hash-check-only[=true|false]
  856. If ``true`` is given, after hash check using
  857. :option:`--check-integrity <-V>` option,
  858. abort download whether or not download is complete.
  859. Default: ``false``
  860. .. option:: --human-readable[=true|false]
  861. Print sizes and speed in human readable format (e.g., 1.2Ki, 3.4Mi)
  862. in the console readout. Default: ``true``
  863. .. option:: --interface=<INTERFACE>
  864. Bind sockets to given interface. You can specify interface name, IP
  865. address and hostname.
  866. Possible Values: interface, IP address, hostname
  867. .. note::
  868. If an interface has multiple addresses, it is highly recommended to
  869. specify IP address explicitly. See also :option:`--disable-ipv6`. If your
  870. system doesn't have :manpage:`getifaddrs(3)`, this option doesn't accept interface
  871. name.
  872. .. option:: --max-download-result=<NUM>
  873. Set maximum number of download result kept in memory. The download
  874. results are completed/error/removed downloads. The download results
  875. are stored in FIFO queue and it can store at most NUM download
  876. results. When queue is full and new download result is created,
  877. oldest download result is removed from the front of the queue and
  878. new one is pushed to the back. Setting big number in this option may
  879. result high memory consumption after thousands of
  880. downloads. Specifying 0 means no download result is kept. Default:
  881. ``1000``
  882. .. option:: --max-resume-failure-tries=<N>
  883. When used with :option:`--always-resume=false, <--always-resume>` aria2 downloads file from
  884. scratch when aria2 detects N number of URIs that does not support
  885. resume. If N is ``0``, aria2 downloads file from scratch when all
  886. given URIs do not support resume. See :option:`--always-resume` option.
  887. Default: ``0``
  888. .. option:: --log-level=<LEVEL>
  889. Set log level to output.
  890. LEVEL is either ``debug``, ``info``, ``notice``, ``warn`` or ``error``.
  891. Default: ``debug``
  892. .. option:: --on-bt-download-complete=<COMMAND>
  893. For BitTorrent, a command specified in :option:`--on-download-complete` is
  894. called after download completed and seeding is over. On the other
  895. hand, this option set the command to be executed after download
  896. completed but before seeding.
  897. See `Event Hook`_ for more details about COMMAND.
  898. Possible Values: ``/path/to/command``
  899. .. option:: --on-download-complete=<COMMAND>
  900. Set the command to be executed after download completed. See
  901. See `Event Hook`_ for more details about COMMAND.
  902. See also :option:`--on-download-stop` option.
  903. Possible Values: ``/path/to/command``
  904. .. option:: --on-download-error=<COMMAND>
  905. Set the command to be executed after download aborted due to error.
  906. See `Event Hook`_ for more details about COMMAND.
  907. See also :option:`--on-download-stop` option. Possible Values:
  908. ``/path/to/command``
  909. .. option:: --on-download-pause=<COMMAND>
  910. Set the command to be executed after download was paused.
  911. See `Event Hook`_ for more details about COMMAND.
  912. Possible Values: ``/path/to/command``
  913. .. option:: --on-download-start=<COMMAND>
  914. Set the command to be executed after download got started.
  915. See `Event Hook`_ for more details about COMMAND.
  916. Possible Values: ``/path/to/command``
  917. .. option:: --on-download-stop=<COMMAND>
  918. Set the command to be executed after download stopped. You can override
  919. the command to be executed for particular download result using
  920. :option:`--on-download-complete` and :option:`--on-download-error`. If they are
  921. specified, command specified in this option is not executed.
  922. See `Event Hook`_ for more details about COMMAND.
  923. Possible Values: ``/path/to/command``
  924. .. option:: --piece-length=<LENGTH>
  925. Set a piece length for HTTP/FTP downloads. This is the boundary when
  926. aria2 splits a file. All splits occur at multiple of this
  927. length. This option will be ignored in BitTorrent downloads. It
  928. will be also ignored if Metalink file contains piece hashes.
  929. Default: ``1M``
  930. .. note::
  931. The possible usecase of :option:`--piece-length`
  932. option is change the request range in one HTTP pipelined request.
  933. To enable HTTP pipelining use
  934. :option:`--enable-http-pipelining`.
  935. .. option:: --show-console-readout[=true|false]
  936. Show console readout. Default: ``true``
  937. .. option:: --summary-interval=<SEC>
  938. Set interval in seconds to output download progress summary.
  939. Setting ``0`` suppresses the output.
  940. Default: ``60``
  941. .. note::
  942. In multi file torrent downloads, the files adjacent forward to the specified files
  943. are also allocated if they share the same piece.
  944. .. option:: -Z, --force-sequential[=true|false]
  945. Fetch URIs in the command-line sequentially and download each URI in a
  946. separate session, like the usual command-line download utilities.
  947. Default: ``false``
  948. .. option:: --max-overall-download-limit=<SPEED>
  949. Set max overall download speed in bytes/sec. ``0`` means
  950. unrestricted. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K). To
  951. limit the download speed per download, use :option:`--max-download-limit`
  952. option. Default: ``0``
  953. .. option:: --max-download-limit=<SPEED>
  954. Set max download speed per each download in bytes/sec. ``0`` means
  955. unrestricted. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K). To
  956. limit the overall download speed, use :option:`--max-overall-download-limit`
  957. option. Default: ``0``
  958. .. option:: --no-conf[=true|false]
  959. Disable loading aria2.conf file.
  960. .. option:: --no-file-allocation-limit=<SIZE>
  961. No file allocation is made for files whose size is smaller than SIZE.
  962. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  963. Default: ``5M``
  964. .. option:: -P, --parameterized-uri[=true|false]
  965. Enable parameterized URI support.
  966. You can specify set of parts: ``http://{sv1,sv2,sv3}/foo.iso``.
  967. Also you can specify numeric sequences with step counter:
  968. ``http://host/image[000-100:2].img``.
  969. A step counter can be omitted.
  970. If all URIs do not point to the same file, such as the second example above,
  971. -Z option is required.
  972. Default: ``false``
  973. .. option:: -q, --quiet[=true|false]
  974. Make aria2 quiet (no console output).
  975. Default: ``false``
  976. .. option:: --realtime-chunk-checksum[=true|false]
  977. Validate chunk of data by calculating checksum while downloading a file if
  978. chunk checksums are provided.
  979. Default: ``true``
  980. .. option:: --remove-control-file[=true|false]
  981. Remove control file before download. Using with
  982. :option:`--allow-overwrite=true, <--allow-overwrite>` download always starts from
  983. scratch. This will be useful for users behind proxy server which
  984. disables resume.
  985. .. option:: --save-session=<FILE>
  986. Save error/unfinished downloads to FILE on exit. You can pass this
  987. output file to aria2c with :option:`--input-file <-i>` option on
  988. restart. If you like the output to be gzipped append a .gz extension to
  989. the file name.
  990. Please note that downloads added by
  991. :func:`aria2.addTorrent` and :func:`aria2.addMetalink` RPC method
  992. and whose metadata could not be saved as a file are not saved.
  993. Downloads removed using :func:`aria2.remove` and
  994. :func:`aria2.forceRemove` will not be saved. GID is also saved with
  995. :option:`gid <--gid>`, but there are some restrictions, see below.
  996. .. note::
  997. Normally, GID of the download itself is saved. But some downloads
  998. use metadata (e.g., BitTorrent and Metalink). In this case, there
  999. are some restrictions.
  1000. 1. magnet URI, and followed by torrent download
  1001. GID of BitTorrent metadata download is saved.
  1002. 2. URI to torrent file, and followed by torrent download
  1003. GID of torrent file download is saved.
  1004. 3. URI to metalink file, and followed by file downloads described in metalink file
  1005. GID of metalink file download is saved.
  1006. 4. local torrent file
  1007. GID of torrent download is saved.
  1008. 5. local metalink file
  1009. Any meaningful GID is not saved.
  1010. .. option:: --save-session-interval=<SEC>
  1011. Save error/unfinished downloads to a file specified by
  1012. :option:`--save-session` option every SEC seconds. If ``0`` is
  1013. given, file will be saved only when aria2 exits. Default: ``0``
  1014. .. option:: --stop=<SEC>
  1015. Stop application after SEC seconds has passed.
  1016. If ``0`` is given, this feature is disabled.
  1017. Default: ``0``
  1018. .. option:: --stop-with-process=<PID>
  1019. Stop application when process PID is not running. This is useful if
  1020. aria2 process is forked from a parent process. The parent process
  1021. can fork aria2 with its own pid and when parent process exits for
  1022. some reason, aria2 can detect it and shutdown itself.
  1023. .. option:: --truncate-console-readout[=true|false]
  1024. Truncate console readout to fit in a single line.
  1025. Default: ``true``
  1026. .. option:: -v, --version
  1027. Print the version number, copyright and the configuration information and
  1028. exit.
  1029. Notes for Options
  1030. ~~~~~~~~~~~~~~~~~
  1031. Optional arguments
  1032. ^^^^^^^^^^^^^^^^^^
  1033. The options that have its argument surrounded by square brackets([])
  1034. take an optional argument. Usually omiting the argument is evaluated to ``true``.
  1035. If you use short form of these options(such as ``-V``) and give
  1036. an argument, then the option name and its argument should be concatenated(e.g.
  1037. ``-Vfalse``). If any spaces are inserted between the option name and the argument,
  1038. the argument will be treated as URI and usually this is not what you expect.
  1039. Units (K and M)
  1040. ^^^^^^^^^^^^^^^
  1041. Some options takes ``K`` and ``M`` to conveniently represent 1024 and
  1042. 1048576 respectively. aria2 detects these characters in
  1043. case-insensitive way. In other words, ``k`` and ``m`` can be used as
  1044. well as ``K`` and ``M`` respectively.
  1045. URI, MAGNET, TORRENT_FILE, METALINK_FILE
  1046. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1047. You can specify multiple URIs in command-line. Unless you specify
  1048. :option:`--force-sequential <-Z>` option, all URIs must point to the same file or downloading will
  1049. fail.
  1050. You can specify arbitrary number of BitTorrent Magnet URI. Please note
  1051. that they are always treated as a separate download. Both hex encoded
  1052. 40 characters Info Hash and Base32 encoded 32 characters Info Hash are
  1053. supported. The multiple ``tr`` parameters are supported. Because
  1054. BitTorrent Magnet URI is likely to contain ``&`` character, it is highly
  1055. recommended to always quote URI with single(``'``) or double(``"``) quotation.
  1056. It is strongly recommended to enable DHT especially when ``tr``
  1057. parameter is missing. See http://www.bittorrent.org/beps/bep_0009.html
  1058. for more details about BitTorrent Magnet URI.
  1059. You can also specify arbitrary number of torrent files and Metalink
  1060. documents stored on a local drive. Please note that they are always
  1061. treated as a separate download. Both Metalink4 and Metalink version
  1062. 3.0 are supported.
  1063. You can specify both torrent file with -T option and URIs. By doing
  1064. this, you can download a file from both torrent swarm and HTTP(S)/FTP
  1065. server at the same time, while the data from HTTP(S)/FTP are uploaded
  1066. to the torrent swarm. For single file torrents, URI can be a complete
  1067. URI pointing to the resource or if URI ends with /, name in torrent
  1068. file in torrent is added. For multi-file torrents, name and path are
  1069. added to form a URI for each file.
  1070. .. note::
  1071. Make sure that URI is quoted with single(``'``) or double(``"``) quotation if it
  1072. contains ``&`` or any characters that have special meaning in shell.
  1073. Resuming Download
  1074. ~~~~~~~~~~~~~~~~~
  1075. Usually, you can resume transfer by just issuing same command(aria2c
  1076. URI) if the previous transfer is made by aria2.
  1077. If the previous transfer is made by a browser or wget like sequential
  1078. download manager, then use :option:`--continue <-c>` option to continue the transfer.
  1079. Event Hook
  1080. ~~~~~~~~~~
  1081. aria2 provides options to specify arbitrary command after specific event
  1082. occurred. Currently following options are available:
  1083. :option:`--on-bt-download-complete`,
  1084. :option:`--on-download-pause`,
  1085. :option:`--on-download-complete`.
  1086. :option:`--on-download-start`,
  1087. :option:`--on-download-error`,
  1088. :option:`--on-download-stop`.
  1089. aria2 passes 3 arguments to specified command when it is executed.
  1090. These arguments are: GID, the number of files and file path. For
  1091. HTTP, FTP downloads, usually the number of files is 1. BitTorrent
  1092. download can contain multiple files.
  1093. If number of files is more than one, file path is first one. In
  1094. other words, this is the value of path key of first struct whose
  1095. selected key is true in the response of
  1096. :func:`aria2.getFiles`
  1097. RPC method.
  1098. If you want to get all file paths, consider to use JSON-RPC/XML-RPC. Please
  1099. note that file path may change during download in HTTP because of
  1100. redirection or Content-Disposition header.
  1101. Let's see an example of how arguments are passed to command:
  1102. .. code-block:: console
  1103. $ cat hook.sh
  1104. #!/bin/sh
  1105. echo "Called with [$1] [$2] [$3]"
  1106. $ aria2c --on-download-complete hook.sh http://example.org/file.iso
  1107. Called with [1] [1] [/path/to/file.iso]
  1108. .. _exit-status:
  1109. EXIT STATUS
  1110. -----------
  1111. Because aria2 can handle multiple downloads at once, it encounters
  1112. lots of errors in a session. aria2 returns the following exit status
  1113. based on the last error encountered.
  1114. 0
  1115. If all downloads were successful.
  1116. 1
  1117. If an unknown error occurred.
  1118. 2
  1119. If time out occurred.
  1120. 3
  1121. If a resource was not found.
  1122. 4
  1123. If aria2 saw the specfied number of "resource not found" error.
  1124. See :option:`--max-file-not-found` option).
  1125. 5
  1126. If a download aborted because download speed was too slow.
  1127. See :option:`--lowest-speed-limit` option)
  1128. 6
  1129. If network problem occurred.
  1130. 7
  1131. If there were unfinished downloads. This error is only reported if
  1132. all finished downloads were successful and there were unfinished
  1133. downloads in a queue when aria2 exited by pressing :kbd:`Ctrl-C` by an user
  1134. or sending TERM or INT signal.
  1135. 8
  1136. If remote server did not support resume when resume was required to
  1137. complete download.
  1138. 9
  1139. If there was not enough disk space available.
  1140. 10
  1141. If piece length was different from one in .aria2 control file. See
  1142. :option:`--allow-piece-length-change` option.
  1143. 11
  1144. If aria2 was downloading same file at that moment.
  1145. 12
  1146. If aria2 was downloading same info hash torrent at that moment.
  1147. 13
  1148. If file already existed. See :option:`--allow-overwrite` option.
  1149. 14
  1150. If renaming file failed. See :option:`--auto-file-renaming` option.
  1151. 15
  1152. If aria2 could not open existing file.
  1153. 16
  1154. If aria2 could not create new file or truncate existing file.
  1155. 17
  1156. If file I/O error occurred.
  1157. 18
  1158. If aria2 could not create directory.
  1159. 19
  1160. If name resolution failed.
  1161. 20
  1162. If aria2 could not parse Metalink document.
  1163. 21
  1164. If FTP command failed.
  1165. 22
  1166. If HTTP response header was bad or unexpected.
  1167. 23
  1168. If too many redirections occurred.
  1169. 24
  1170. If HTTP authorization failed.
  1171. 25
  1172. If aria2 could not parse bencoded file(usually ".torrent" file).
  1173. 26
  1174. If ".torrent" file was corrupted or missing information that aria2 needed.
  1175. 27
  1176. If Magnet URI was bad.
  1177. 28
  1178. If bad/unrecognized option was given or unexpected option argument
  1179. was given.
  1180. 29
  1181. If the remote server was unable to handle the request due to a
  1182. temporary overloading or maintenance.
  1183. 30
  1184. If aria2 could not parse JSON-RPC request.
  1185. .. note::
  1186. An error occurred in a finished download will not be reported
  1187. as exit status.
  1188. ENVIRONMENT
  1189. -----------
  1190. aria2 recognizes the following environment variables.
  1191. ``http_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1192. Specify proxy server for use in HTTP.
  1193. Overrides http-proxy value in configuration file.
  1194. The command-line option :option:`--http-proxy` overrides this value.
  1195. ``https_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1196. Specify proxy server for use in HTTPS.
  1197. Overrides https-proxy value in configuration file.
  1198. The command-line option :option:`--https-proxy` overrides this value.
  1199. ``ftp_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1200. Specify proxy server for use in FTP.
  1201. Overrides ftp-proxy value in configuration file.
  1202. The command-line option :option:`--ftp-proxy` overrides this value.
  1203. ``all_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1204. Specify proxy server for use if no protocol-specific proxy is specified.
  1205. Overrides all-proxy value in configuration file.
  1206. The command-line option :option:`--all-proxy` overrides this value.
  1207. .. note::
  1208. Although aria2 accepts ``ftp://`` and ``https://`` scheme in proxy URI, it
  1209. simply assumes that ``http://`` is specified and does not change its
  1210. behavior based on the specified scheme.
  1211. ``no_proxy [DOMAIN,...]``
  1212. Specify comma-separated hostname, domains and network address with
  1213. or without CIDR block to which proxy should not be used. Overrides
  1214. no-proxy value in configuration file. The command-line option
  1215. :option:`--no-proxy` overrides this value.
  1216. FILES
  1217. -----
  1218. aria2.conf
  1219. ~~~~~~~~~~
  1220. By default, aria2 parses ``$HOME/.aria2/aria2.conf`` as a
  1221. configuraiton file. You can specify the path to configuration file
  1222. using :option:`--conf-path` option. If you don't want to use the
  1223. configuraiton file, use :option:`--no-conf` option.
  1224. The configuration file is a text file and has 1 option per each
  1225. line. In each line, you can specify name-value pair in the format:
  1226. ``NAME=VALUE``, where name is the long command-line option name without
  1227. ``--`` prefix. You can use same syntax for the command-line option. The
  1228. lines beginning ``#`` are treated as comments::
  1229. # sample configuration file for aria2c
  1230. listen-port=60000
  1231. dht-listen-port=60000
  1232. seed-ratio=1.0
  1233. max-upload-limit=50K
  1234. ftp-pasv=true
  1235. .. note::
  1236. The confidential information such as user/password might be included
  1237. in the configuration file. It is recommended to change file mode
  1238. bits of the configuration file (e.g., ``chmod 600 aria2.conf``), so
  1239. that other user cannot see the contents of the file.
  1240. dht.dat
  1241. ~~~~~~~~
  1242. By default, the routing table of IPv4 DHT is saved to the path
  1243. ``$HOME/.aria2/dht.dat`` and the routing table of IPv6 DHT is saved to
  1244. the path ``$HOME/.aria2/dht6.dat``.
  1245. Netrc
  1246. ~~~~~
  1247. Netrc support is enabled by default for HTTP(S)/FTP. To disable netrc
  1248. support, specify :option:`--no-netrc <-n>` option. Your .netrc file should have correct
  1249. permissions(600).
  1250. If machine name starts ``.``, aria2 performs domain-match instead of
  1251. exact match. This is an extension of aria2. For example of domain
  1252. match, imagine the following .netrc entry::
  1253. machine .example.org login myid password mypasswd
  1254. ``aria2.example.org`` domain-matches ``.example.org`` and uses ``myid`` and
  1255. ``mypasswd``.
  1256. Some domain-match example follow: ``example.net`` does not domain-match
  1257. ``.example.org``. ``example.org`` does not domain-match ``.example.org``
  1258. because of preceding ``.``. If you want to match ``example.org``, specify
  1259. ``example.org``.
  1260. Control File
  1261. ~~~~~~~~~~~~
  1262. aria2 uses a control file to track the progress of a download. A
  1263. control file is placed in the same directory as the downloading file
  1264. and its filename is the filename of downloading file with ``.aria2``
  1265. appended. For example, if you are downloading file.zip, then the
  1266. control file should be file.zip.aria2. (There is a exception for this
  1267. naming convention. If you are downloading a multi torrent, its
  1268. control file is the "top directory" name of the torrent with ``.aria2``
  1269. appended. The "top directory" name is a value of "name" key in "info"
  1270. directory in a torrent file.)
  1271. Usually a control file is deleted once download completed. If aria2
  1272. decides that download cannot be resumed(for example, when downloading
  1273. a file from a HTTP server which doesn't support resume), a control
  1274. file is not created.
  1275. Normally if you lose a control file, you cannot resume download. But
  1276. if you have a torrent or metalink with chunk checksums for the file,
  1277. you can resume the download without a control file by giving -V option
  1278. to aria2c in command-line.
  1279. .. _input-file:
  1280. Input File
  1281. ~~~~~~~~~~
  1282. The input file can contain a list of URIs for aria2 to download. You
  1283. can specify multiple URIs for a single entity: separate URIs on a
  1284. single line using the TAB character.
  1285. Each line is treated as if it is provided in command-line argument.
  1286. Therefore they are affected by :option:`--force-sequential <-Z>` and :option:`--parameterized-uri <-P>` options.
  1287. Since URIs in the input file are directly read by aria2, they must not
  1288. be quoted with single(``'``) or double(``"``) quotation.
  1289. Lines starting with ``#`` are treated as comments and skipped.
  1290. Additionally, the following options can be specified after each line
  1291. of URIs. These optional lines must start with white space(s).
  1292. .. hlist::
  1293. :columns: 3
  1294. * :option:`all-proxy <--all-proxy>`
  1295. * :option:`all-proxy-passwd <--all-proxy-passwd>`
  1296. * :option:`all-proxy-user <--all-proxy-user>`
  1297. * :option:`allow-overwrite <--allow-overwrite>`
  1298. * :option:`allow-piece-length-change <--allow-piece-length-change>`
  1299. * :option:`always-resume <--always-resume>`
  1300. * :option:`async-dns <--async-dns>`
  1301. * :option:`auto-file-renaming <--auto-file-renaming>`
  1302. * :option:`bt-enable-lpd <--bt-enable-lpd>`
  1303. * :option:`bt-exclude-tracker <--bt-exclude-tracker>`
  1304. * :option:`bt-external-ip <--bt-external-ip>`
  1305. * :option:`bt-hash-check-seed <--bt-hash-check-seed>`
  1306. * :option:`bt-max-peers <--bt-max-peers>`
  1307. * :option:`bt-metadata-only <--bt-metadata-only>`
  1308. * :option:`bt-min-crypto-level <--bt-min-crypto-level>`
  1309. * :option:`bt-prioritize-piece <--bt-prioritize-piece>`
  1310. * :option:`bt-remove-unselected-file <--bt-remove-unselected-file>`
  1311. * :option:`bt-request-peer-speed-limit <--bt-request-peer-speed-limit>`
  1312. * :option:`bt-require-crypto <--bt-require-crypto>`
  1313. * :option:`bt-save-metadata <--bt-save-metadata>`
  1314. * :option:`bt-seed-unverified <--bt-seed-unverified>`
  1315. * :option:`bt-stop-timeout <--bt-stop-timeout>`
  1316. * :option:`bt-tracker <--bt-tracker>`
  1317. * :option:`bt-tracker-connect-timeout <--bt-tracker-connect-timeout>`
  1318. * :option:`bt-tracker-interval <--bt-tracker-interval>`
  1319. * :option:`bt-tracker-timeout <--bt-tracker-timeout>`
  1320. * :option:`check-integrity <-V>`
  1321. * :option:`checksum <--checksum>`
  1322. * :option:`conditional-get <--conditional-get>`
  1323. * :option:`connect-timeout <--connect-timeout>`
  1324. * :option:`continue <-c>`
  1325. * :option:`dir <-d>`
  1326. * :option:`dry-run <--dry-run>`
  1327. * :option:`enable-http-keep-alive <--enable-http-keep-alive>`
  1328. * :option:`enable-http-pipelining <--enable-http-pipelining>`
  1329. * :option:`enable-mmap <--enable-mmap>`
  1330. * :option:`enable-peer-exchange <--enable-peer-exchange>`
  1331. * :option:`file-allocation <--file-allocation>`
  1332. * :option:`follow-metalink <--follow-metalink>`
  1333. * :option:`follow-torrent <--follow-torrent>`
  1334. * :option:`force-save <--force-save>`
  1335. * :option:`ftp-passwd <--ftp-passwd>`
  1336. * :option:`ftp-pasv <-p>`
  1337. * :option:`ftp-proxy <--ftp-proxy>`
  1338. * :option:`ftp-proxy-passwd <--ftp-proxy-passwd>`
  1339. * :option:`ftp-proxy-user <--ftp-proxy-user>`
  1340. * :option:`ftp-reuse-connection <--ftp-reuse-connection>`
  1341. * :option:`ftp-type <--ftp-type>`
  1342. * :option:`ftp-user <--ftp-user>`
  1343. * :option:`gid <--gid>`
  1344. * :option:`hash-check-only <--hash-check-only>`
  1345. * :option:`header <--header>`
  1346. * :option:`http-accept-gzip <--http-accept-gzip>`
  1347. * :option:`http-auth-challenge <--http-auth-challenge>`
  1348. * :option:`http-no-cache <--http-no-cache>`
  1349. * :option:`http-passwd <--http-passwd>`
  1350. * :option:`http-proxy <--http-proxy>`
  1351. * :option:`http-proxy-passwd <--http-proxy-passwd>`
  1352. * :option:`http-proxy-user <--http-proxy-user>`
  1353. * :option:`http-user <--http-user>`
  1354. * :option:`https-proxy <--https-proxy>`
  1355. * :option:`https-proxy-passwd <--https-proxy-passwd>`
  1356. * :option:`https-proxy-user <--https-proxy-user>`
  1357. * :option:`index-out <-O>`
  1358. * :option:`lowest-speed-limit <--lowest-speed-limit>`
  1359. * :option:`max-connection-per-server <-x>`
  1360. * :option:`max-download-limit <--max-download-limit>`
  1361. * :option:`max-file-not-found <--max-file-not-found>`
  1362. * :option:`max-resume-failure-tries <--max-resume-failure-tries>`
  1363. * :option:`max-tries <-m>`
  1364. * :option:`max-upload-limit <-u>`
  1365. * :option:`metalink-base-uri <--metalink-base-uri>`
  1366. * :option:`metalink-enable-unique-protocol <--metalink-enable-unique-protocol>`
  1367. * :option:`metalink-language <--metalink-language>`
  1368. * :option:`metalink-location <--metalink-location>`
  1369. * :option:`metalink-os <--metalink-os>`
  1370. * :option:`metalink-preferred-protocol <--metalink-preferred-protocol>`
  1371. * :option:`metalink-version <--metalink-version>`
  1372. * :option:`min-split-size <-k>`
  1373. * :option:`no-file-allocation-limit <--no-file-allocation-limit>`
  1374. * :option:`no-netrc <-n>`
  1375. * :option:`no-proxy <--no-proxy>`
  1376. * :option:`out <-o>`
  1377. * :option:`parameterized-uri <-P>`
  1378. * :option:`pause <--pause>`
  1379. * :option:`piece-length <--piece-length>`
  1380. * :option:`proxy-method <--proxy-method>`
  1381. * :option:`realtime-chunk-checksum <--realtime-chunk-checksum>`
  1382. * :option:`referer <--referer>`
  1383. * :option:`remote-time <-R>`
  1384. * :option:`remove-control-file <--remove-control-file>`
  1385. * :option:`retry-wait <--retry-wait>`
  1386. * :option:`reuse-uri <--reuse-uri>`
  1387. * :option:`rpc-save-upload-metadata <--rpc-save-upload-metadata>`
  1388. * :option:`seed-ratio <--seed-ratio>`
  1389. * :option:`seed-time <--seed-time>`
  1390. * :option:`select-file <--select-file>`
  1391. * :option:`split <-s>`
  1392. * :option:`stream-piece-selector <--stream-piece-selector>`
  1393. * :option:`timeout <-t>`
  1394. * :option:`uri-selector <--uri-selector>`
  1395. * :option:`use-head <--use-head>`
  1396. * :option:`user-agent <-U>`
  1397. These options have exactly same meaning of the ones in the
  1398. command-line options, but it just applies to the URIs it belongs to.
  1399. Please note that for options in input file ``--`` prefix must be
  1400. stripped.
  1401. For example, the content of uri.txt is::
  1402. http://server/file.iso http://mirror/file.iso
  1403. dir=/iso_images
  1404. out=file.img
  1405. http://foo/bar
  1406. If aria2 is executed with ``-i uri.txt -d /tmp`` options, then
  1407. ``file.iso`` is saved as ``/iso_images/file.img`` and it is downloaded
  1408. from ``http://server/file.iso`` and ``http://mirror/file.iso``. The file
  1409. ``bar`` is downloaded from ``http://foo/bar`` and saved as ``/tmp/bar``.
  1410. In some cases, :option:`out <-o>` parameter has no effect.
  1411. See note of :option:`--out <-o>`
  1412. option for the restrictions.
  1413. Server Performance Profile
  1414. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1415. This section describes the format of server performance profile. The
  1416. file is plain text and each line has several ``NAME=VALUE`` pair,
  1417. delimited by comma. Currently following NAMEs are recognized:
  1418. ``host``
  1419. Hostname of the server. Required.
  1420. ``protocol``
  1421. Protocol for this profile, such as ftp, http. Required.
  1422. ``dl_speed``
  1423. The average download speed observed in the previous download in
  1424. bytes per sec. Required.
  1425. ``sc_avg_speed``
  1426. The average download speed observed in the previous download in
  1427. bytes per sec. This value is only updated if the download is done in
  1428. single connection environment and only used by
  1429. AdaptiveURISelector. Optional.
  1430. ``mc_avg_speed``
  1431. The average download speed observed in the previous download in
  1432. bytes per sec. This value is only updated if the download is done in
  1433. multi connection environment and only used by
  1434. AdaptiveURISelector. Optional.
  1435. ``counter``
  1436. How many times the server is used. Currently this value is only used
  1437. by AdaptiveURISelector. Optional.
  1438. ``last_updated``
  1439. Last contact time in GMT with this server, specified in the seconds
  1440. since the Epoch(00:00:00 on January 1, 1970, UTC). Required.
  1441. ``status``
  1442. ERROR is set when server cannot be reached or out-of-service or
  1443. timeout occurred. Otherwise, OK is set.
  1444. Those fields must exist in one line. The order of the fields is not
  1445. significant. You can put pairs other than the above; they are simply
  1446. ignored.
  1447. An example follows::
  1448. host=localhost, protocol=http, dl_speed=32000, last_updated=1222491640, status=OK
  1449. host=localhost, protocol=ftp, dl_speed=0, last_updated=1222491632, status=ERROR
  1450. RPC INTERFACE
  1451. -------------
  1452. aria2 provides JSON-RPC over HTTP and XML-RPC over HTTP and they
  1453. basically have the same functionality. aria2 also provides JSON-RPC
  1454. over WebSocket. JSON-RPC over WebSocket uses same method signatures
  1455. and response format with JSON-RPC over HTTP, but it additionally has
  1456. server-initiated notifications. See `JSON-RPC over WebSocket`_ section for details.
  1457. The request path of JSON-RPC interface (for both over HTTP and over
  1458. WebSocket) is ``/jsonrpc``. The request path of XML-RPC interface is
  1459. ``/rpc``.
  1460. The WebSocket URI for JSON-RPC over WebSocket is
  1461. ``ws://HOST:PORT/jsonrpc``. If you enabled SSL/TLS encryption, use
  1462. ``wss://HOST:PORT/jsonrpc`` instead.
  1463. The implemented JSON-RPC is based on
  1464. JSON-RPC 2.0 <http://jsonrpc.org/specification>, and
  1465. supports HTTP POST and GET (JSONP). Using WebSocket as a transport is
  1466. the original extension of aria2.
  1467. The JSON-RPC interface does not support notification in HTTP, but the
  1468. RPC server will send the notification in WebSocket. It also does not
  1469. support floating point number. The character encoding must be UTF-8.
  1470. When reading following document for JSON-RPC, interpret struct as JSON
  1471. object.
  1472. Terminology
  1473. ~~~~~~~~~~~
  1474. GID
  1475. GID(or gid) is the key to manage each download. Each download has an
  1476. unique GID. GID is stored in 64 bits binary data in aria2. For RPC
  1477. access, it is represented in hex string of 16 characters (e.g.,
  1478. ``2089b05ecca3d829``). Normally, aria2 generates this GID for each
  1479. download, but the user can specify GID manually using :option:`--gid
  1480. <--gid>` option. When querying download by GID, you can specify the
  1481. prefix of GID as long as it is a unique prefix among others.
  1482. Methods
  1483. ~~~~~~~
  1484. All code examples come from Python2.7 interpreter.
  1485. .. function:: aria2.addUri(uris[, options[, position]])
  1486. This method adds new HTTP(S)/FTP/BitTorrent Magnet URI. *uris* is of
  1487. type array and its element is URI which is of type string. For
  1488. BitTorrent Magnet URI, *uris* must have only one element and it should
  1489. be BitTorrent Magnet URI. URIs in *uris* must point to the same file.
  1490. If you mix other URIs which point to another file, aria2 does not
  1491. complain but download may fail. *options* is of type struct and its
  1492. members are a pair of option name and value. See :ref:`rpc_options` below for
  1493. more details. If *position* is given as an integer starting from 0,
  1494. the new download is inserted at *position* in the waiting queue. If
  1495. *position* is not given or *position* is larger than the size of the
  1496. queue, it is appended at the end of the queue. This method returns
  1497. GID of registered download.
  1498. **JSON-RPC Example**
  1499. The following example adds ``http://example.org/file``::
  1500. >>> import urllib2, json
  1501. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1502. ... 'method':'aria2.addUri',
  1503. ... 'params':[['http://example.org/file']]})
  1504. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1505. >>> c.read()
  1506. '{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'
  1507. **XML-RPC Example**
  1508. The following example adds ``http://example.org/file``::
  1509. >>> import xmlrpclib
  1510. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1511. >>> s.aria2.addUri(['http://example.org/file'])
  1512. '2089b05ecca3d829'
  1513. The following example adds 2 sources and some options::
  1514. >>> s.aria2.addUri(['http://example.org/file', 'http://mirror/file'],
  1515. dict(dir="/tmp"))
  1516. 'd2703803b52216d1'
  1517. The following example adds a download and insert it to the front of
  1518. waiting downloads::
  1519. >>> s.aria2.addUri(['http://example.org/file'], {}, 0)
  1520. 'ca3d829cee549a4d'
  1521. .. function:: aria2.addTorrent(torrent[, uris[, options[, position]]])
  1522. This method adds BitTorrent download by uploading ".torrent" file.
  1523. If you want to add BitTorrent Magnet URI, use :func:`aria2.addUri`
  1524. method instead. *torrent* is of type base64 which contains
  1525. Base64-encoded ".torrent" file. *uris* is of type array and its
  1526. element is URI which is of type string. *uris* is used for
  1527. Web-seeding. For single file torrents, URI can be a complete URI
  1528. pointing to the resource or if URI ends with /, name in torrent file
  1529. is added. For multi-file torrents, name and path in torrent are
  1530. added to form a URI for each file. *options* is of type struct and
  1531. its members are a pair of option name and value. See
  1532. :ref:`rpc_options` below for more details. If *position* is given
  1533. as an integer starting from 0, the new download is inserted at
  1534. *position* in the waiting queue. If *position* is not given or
  1535. *position* is larger than the size of the queue, it is appended at
  1536. the end of the queue. This method returns GID of registered
  1537. download. If :option:`--rpc-save-upload-metadata` is ``true``, the
  1538. uploaded data is saved as a file named hex string of SHA-1 hash of
  1539. data plus ".torrent" in the directory specified by :option:`--dir
  1540. <-d>` option. The example of filename is
  1541. ``0a3893293e27ac0490424c06de4d09242215f0a6.torrent``. If same file
  1542. already exists, it is overwritten. If the file cannot be saved
  1543. successfully or :option:`--rpc-save-upload-metadata` is ``false``,
  1544. the downloads added by this method are not saved by
  1545. :option:`--save-session`.
  1546. The following examples add local file ``file.torrent``.
  1547. **JSON-RPC Example**
  1548. ::
  1549. >>> import urllib2, json, base64
  1550. >>> torrent = base64.b64encode(open('file.torrent').read())
  1551. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'asdf',
  1552. ... 'method':'aria2.addTorrent', 'params':[torrent]})
  1553. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1554. >>> c.read()
  1555. '{"id":"asdf","jsonrpc":"2.0","result":"2089b05ecca3d829"}'
  1556. **XML-RPC Example**
  1557. ::
  1558. >>> import xmlrpclib
  1559. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1560. >>> s.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
  1561. '2089b05ecca3d829'
  1562. .. function:: aria2.addMetalink(metalink[, options[, position]])
  1563. This method adds Metalink download by uploading ".metalink" file.
  1564. *metalink* is of type base64 which contains Base64-encoded
  1565. ".metalink" file. *options* is of type struct and its members are a
  1566. pair of option name and value. See :ref:`rpc_options` below for more
  1567. details. If *position* is given as an integer starting from 0, the
  1568. new download is inserted at *position* in the waiting queue. If
  1569. *position* is not given or *position* is larger than the size of the
  1570. queue, it is appended at the end of the queue. This method returns
  1571. array of GID of registered download. If
  1572. :option:`--rpc-save-upload-metadata` is ``true``, the uploaded data
  1573. is saved as a file named hex string of SHA-1 hash of data plus
  1574. ".metalink" in the directory specified by :option:`--dir <-d>`
  1575. option. The example of filename is
  1576. ``0a3893293e27ac0490424c06de4d09242215f0a6.metalink``. If same file
  1577. already exists, it is overwritten. If the file cannot be saved
  1578. successfully or :option:`--rpc-save-upload-metadata` is ``false``,
  1579. the downloads added by this method are not saved by
  1580. :option:`--save-session`.
  1581. The following examples add local file file.meta4.
  1582. **JSON-RPC Example**
  1583. ::
  1584. >>> import urllib2, json, base64
  1585. >>> metalink = base64.b64encode(open('file.meta4').read())
  1586. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1587. ... 'method':'aria2.addMetalink',
  1588. ... 'params':[metalink]})
  1589. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1590. >>> c.read()
  1591. '{"id":"qwer","jsonrpc":"2.0","result":["2089b05ecca3d829"]}'
  1592. **XML-RPC Example**
  1593. ::
  1594. >>> import xmlrpclib
  1595. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1596. >>> s.aria2.addMetalink(xmlrpclib.Binary(open('file.meta4').read()))
  1597. ['2089b05ecca3d829']
  1598. .. function:: aria2.remove(gid)
  1599. This method removes the download denoted by *gid*. *gid* is of type
  1600. string. If specified download is in progress, it is stopped at
  1601. first. The status of removed download becomes ``removed``. This method
  1602. returns GID of removed download.
  1603. The following examples remove download GID#2089b05ecca3d829.
  1604. **JSON-RPC Example**
  1605. ::
  1606. >>> import urllib2, json
  1607. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1608. ... 'method':'aria2.remove',
  1609. ... 'params':['2089b05ecca3d829']})
  1610. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1611. >>> c.read()
  1612. '{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'
  1613. **XML-RPC Example**
  1614. ::
  1615. >>> import xmlrpclib
  1616. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1617. >>> s.aria2.remove('2089b05ecca3d829')
  1618. '2089b05ecca3d829'
  1619. .. function:: aria2.forceRemove(gid)
  1620. This method removes the download denoted by *gid*. This method
  1621. behaves just like :func:`aria2.remove` except that this method removes
  1622. download without any action which takes time such as contacting
  1623. BitTorrent tracker.
  1624. .. function:: aria2.pause(gid)
  1625. This method pauses the download denoted by *gid*. *gid* is of type
  1626. string. The status of paused download becomes ``paused``. If the
  1627. download is active, the download is placed on the first position of
  1628. waiting queue. As long as the status is ``paused``, the download is not
  1629. started. To change status to ``waiting``, use :func:`aria2.unpause` method.
  1630. This method returns GID of paused download.
  1631. .. function:: aria2.pauseAll()
  1632. This method is equal to calling :func:`aria2.pause` for every active/waiting
  1633. download. This methods returns ``OK`` for success.
  1634. .. function:: aria2.forcePause(pid)
  1635. This method pauses the download denoted by *gid*. This method
  1636. behaves just like :func:`aria2.pause` except that this method pauses
  1637. download without any action which takes time such as contacting
  1638. BitTorrent tracker.
  1639. .. function:: aria2.forcePauseAll()
  1640. This method is equal to calling :func:`aria2.forcePause` for every
  1641. active/waiting download. This methods returns ``OK`` for success.
  1642. .. function:: aria2.unpause(gid)
  1643. This method changes the status of the download denoted by *gid* from
  1644. ``paused`` to ``waiting``. This makes the download eligible to restart.
  1645. *gid* is of type string. This method returns GID of unpaused
  1646. download.
  1647. .. function:: aria2.unpauseAll()
  1648. This method is equal to calling :func:`aria2.unpause` for every active/waiting
  1649. download. This methods returns ``OK`` for success.
  1650. .. function:: aria2.tellStatus(gid[, keys])
  1651. This method returns download progress of the download denoted by
  1652. *gid*. *gid* is of type string. *keys* is array of string. If it is
  1653. specified, the response contains only keys in *keys* array. If *keys*
  1654. is empty or not specified, the response contains all keys. This is
  1655. useful when you just want specific keys and avoid unnecessary
  1656. transfers. For example, ``aria2.tellStatus("2089b05ecca3d829", ["gid", "status"])``
  1657. returns *gid* and 'status' key. The response is of type struct and it
  1658. contains following keys. The value type is string.
  1659. ``gid``
  1660. GID of this download.
  1661. ``status``
  1662. ``active`` for currently downloading/seeding entry. ``waiting`` for the
  1663. entry in the queue; download is not started. ``paused`` for the
  1664. paused entry. ``error`` for the stopped download because of
  1665. error. ``complete`` for the stopped and completed download. ``removed``
  1666. for the download removed by user.
  1667. ``totalLength``
  1668. Total length of this download in bytes.
  1669. ``completedLength``
  1670. Completed length of this download in bytes.
  1671. ``uploadLength``
  1672. Uploaded length of this download in bytes.
  1673. ``bitfield``
  1674. Hexadecimal representation of the download progress. The highest bit
  1675. corresponds to piece index 0. The set bits indicate the piece is
  1676. available and unset bits indicate the piece is missing. The spare
  1677. bits at the end are set to zero. When download has not started yet,
  1678. this key will not be included in the response.
  1679. ``downloadSpeed``
  1680. Download speed of this download measured in bytes/sec.
  1681. ``uploadSpeed``
  1682. Upload speed of this download measured in bytes/sec.
  1683. ``infoHash``
  1684. InfoHash. BitTorrent only.
  1685. ``numSeeders``
  1686. The number of seeders the client has connected to. BitTorrent only.
  1687. ``pieceLength``
  1688. Piece length in bytes.
  1689. ``numPieces``
  1690. The number of pieces.
  1691. ``connections``
  1692. The number of peers/servers the client has connected to.
  1693. ``errorCode``
  1694. The last error code occurred in this download. The value is of type
  1695. string. The error codes are defined in `EXIT STATUS`_ section. This value is only available for
  1696. stopped/completed downloads.
  1697. ``followedBy``
  1698. List of GIDs which are generated by the consequence of this
  1699. download. For example, when aria2 downloaded Metalink file, it
  1700. generates downloads described in it(see :option:`--follow-metalink`
  1701. option). This value is useful to track these auto generated
  1702. downloads. If there is no such downloads, this key will not
  1703. be included in the response.
  1704. ``belongsTo``
  1705. GID of a parent download. Some downloads are a part of another
  1706. download. For example, if a file in Metalink has BitTorrent
  1707. resource, the download of ".torrent" is a part of that file. If this
  1708. download has no parent, this key will not be included in the
  1709. response.
  1710. ``dir``
  1711. Directory to save files.
  1712. ``files``
  1713. Returns the list of files. The element of list is the same struct
  1714. used in :func:`aria2.getFiles` method.
  1715. ``bittorrent``
  1716. Struct which contains information retrieved from .torrent
  1717. file. BitTorrent only. It contains following keys.
  1718. ``announceList``
  1719. List of lists of announce URI. If ".torrent" file contains announce
  1720. and no announce-list, announce is converted to announce-list
  1721. format.
  1722. ``comment``
  1723. The comment for the torrent. ``comment.utf-8`` is used if available.
  1724. ``creationDate``
  1725. The creation time of the torrent. The value is an integer since
  1726. the Epoch, measured in seconds.
  1727. ``mode``
  1728. File mode of the torrent. The value is either ``single`` or ``multi``.
  1729. ``info``
  1730. Struct which contains data from Info dictionary. It contains
  1731. following keys.
  1732. ``name``
  1733. name in info dictionary. ``name.utf-8`` is used if available.
  1734. **JSON-RPC Example**
  1735. The following example gets information about download GID#2089b05ecca3d829::
  1736. >>> import urllib2, json
  1737. >>> from pprint import pprint
  1738. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1739. ... 'method':'aria2.tellStatus',
  1740. ... 'params':['2089b05ecca3d829']})
  1741. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1742. >>> pprint(json.loads(c.read()))
  1743. {u'id': u'qwer',
  1744. u'jsonrpc': u'2.0',
  1745. u'result': {u'bitfield': u'0000000000',
  1746. u'completedLength': u'901120',
  1747. u'connections': u'1',
  1748. u'dir': u'/downloads',
  1749. u'downloadSpeed': u'15158',
  1750. u'files': [{u'index': u'1',
  1751. u'length': u'34896138',
  1752. u'completedLength': u'34896138',
  1753. u'path': u'/downloads/file',
  1754. u'selected': u'true',
  1755. u'uris': [{u'status': u'used',
  1756. u'uri': u'http://example.org/file'}]}],
  1757. u'gid': u'2089b05ecca3d829',
  1758. u'numPieces': u'34',
  1759. u'pieceLength': u'1048576',
  1760. u'status': u'active',
  1761. u'totalLength': u'34896138',
  1762. u'uploadLength': u'0',
  1763. u'uploadSpeed': u'0'}}
  1764. The following example gets information specifying keys you are
  1765. interested in::
  1766. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1767. ... 'method':'aria2.tellStatus',
  1768. ... 'params':['2089b05ecca3d829',
  1769. ... ['gid',
  1770. ... 'totalLength',
  1771. ... 'completedLength']]})
  1772. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1773. >>> pprint(json.loads(c.read()))
  1774. {u'id': u'qwer',
  1775. u'jsonrpc': u'2.0',
  1776. u'result': {u'completedLength': u'5701632',
  1777. u'gid': u'2089b05ecca3d829',
  1778. u'totalLength': u'34896138'}}
  1779. **XML-RPC Example**
  1780. The following example gets information about download GID#2089b05ecca3d829::
  1781. >>> import xmlrpclib
  1782. >>> from pprint import pprint
  1783. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1784. >>> r = s.aria2.tellStatus('2089b05ecca3d829')
  1785. >>> pprint(r)
  1786. {'bitfield': 'ffff80',
  1787. 'completedLength': '34896138',
  1788. 'connections': '0',
  1789. 'dir': '/downloads',
  1790. 'downloadSpeed': '0',
  1791. 'errorCode': '0',
  1792. 'files': [{'index': '1',
  1793. 'length': '34896138',
  1794. 'completedLength': '34896138',
  1795. 'path': '/downloads/file',
  1796. 'selected': 'true',
  1797. 'uris': [{'status': 'used',
  1798. 'uri': 'http://example.org/file'}]}],
  1799. 'gid': '2089b05ecca3d829',
  1800. 'numPieces': '17',
  1801. 'pieceLength': '2097152',
  1802. 'status': 'complete',
  1803. 'totalLength': '34896138',
  1804. 'uploadLength': '0',
  1805. 'uploadSpeed': '0'}
  1806. The following example gets information specifying keys you are
  1807. interested in::
  1808. >>> r = s.aria2.tellStatus('2089b05ecca3d829', ['gid', 'totalLength', 'completedLength'])
  1809. >>> pprint(r)
  1810. {'completedLength': '34896138', 'gid': '2089b05ecca3d829', 'totalLength': '34896138'}
  1811. .. function:: aria2.getUris(gid)
  1812. This method returns URIs used in the download denoted by *gid*. *gid*
  1813. is of type string. The response is of type array and its element is of
  1814. type struct and it contains following keys. The value type is string.
  1815. ``uri``
  1816. URI
  1817. ``status``
  1818. 'used' if the URI is already used. 'waiting' if the URI is waiting
  1819. in the queue.
  1820. **JSON-RPC Example**
  1821. ::
  1822. >>> import urllib2, json
  1823. >>> from pprint import pprint
  1824. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1825. ... 'method':'aria2.getUris',
  1826. ... 'params':['2089b05ecca3d829']})
  1827. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1828. >>> pprint(json.loads(c.read()))
  1829. {u'id': u'qwer',
  1830. u'jsonrpc': u'2.0',
  1831. u'result': [{u'status': u'used',
  1832. u'uri': u'http://example.org/file'}]}
  1833. **XML-RPC Example**
  1834. ::
  1835. >>> import xmlrpclib
  1836. >>> from pprint import pprint
  1837. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1838. >>> r = s.aria2.getUris('2089b05ecca3d829')
  1839. >>> pprint(r)
  1840. [{'status': 'used', 'uri': 'http://example.org/file'}]
  1841. .. function:: aria2.getFiles(gid)
  1842. This method returns file list of the download denoted by *gid*. *gid*
  1843. is of type string. The response is of type array and its element is of
  1844. type struct and it contains following keys. The value type is string.
  1845. ``index``
  1846. Index of file. Starting with 1. This is the same order with the
  1847. files in multi-file torrent.
  1848. ``path``
  1849. File path.
  1850. ``length``
  1851. File size in bytes.
  1852. ``completedLength``
  1853. Completed length of this file in bytes. Please note that it is
  1854. possible that sum of completedLength is less than completedLength in
  1855. :func:`aria2.tellStatus` method.
  1856. This is because completedLength in
  1857. :func:`aria2.getFiles`
  1858. only calculates completed pieces. On the other hand, completedLength
  1859. in
  1860. :func:`aria2.tellStatus` takes into account
  1861. of partially completed piece.
  1862. ``selected``
  1863. ``true`` if this file is selected by :option:`--select-file` option. If
  1864. :option:`--select-file` is not specified or this is single torrent or no
  1865. torrent download, this value is always ``true``. Otherwise ``false``.
  1866. ``uris``
  1867. Returns the list of URI for this file. The element of list is the
  1868. same struct used in :func:`aria2.getUris` method.
  1869. **JSON-RPC Example**
  1870. ::
  1871. >>> import urllib2, json
  1872. >>> from pprint import pprint
  1873. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1874. ... 'method':'aria2.getFiles',
  1875. ... 'params':['2089b05ecca3d829']})
  1876. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1877. >>> pprint(json.loads(c.read()))
  1878. {u'id': u'qwer',
  1879. u'jsonrpc': u'2.0',
  1880. u'result': [{u'index': u'1',
  1881. u'length': u'34896138',
  1882. u'completedLength': u'34896138',
  1883. u'path': u'/downloads/file',
  1884. u'selected': u'true',
  1885. u'uris': [{u'status': u'used',
  1886. u'uri': u'http://example.org/file'}]}]}
  1887. **XML-RPC Example**
  1888. ::
  1889. >>> import xmlrpclib
  1890. >>> from pprint import pprint
  1891. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1892. >>> r = s.aria2.getFiles('2089b05ecca3d829')
  1893. >>> pprint(r)
  1894. [{'index': '1',
  1895. 'length': '34896138',
  1896. 'completedLength': '34896138',
  1897. 'path': '/downloads/file',
  1898. 'selected': 'true',
  1899. 'uris': [{'status': 'used',
  1900. 'uri': 'http://example.org/file'}]}]
  1901. .. function:: aria2.getPeers(gid)
  1902. This method returns peer list of the download denoted by *gid*. *gid*
  1903. is of type string. This method is for BitTorrent only. The response
  1904. is of type array and its element is of type struct and it contains
  1905. following keys. The value type is string.
  1906. ``peerId``
  1907. Percent-encoded peer ID.
  1908. ``ip``
  1909. IP address of the peer.
  1910. ``port``
  1911. Port number of the peer.
  1912. ``bitfield``
  1913. Hexadecimal representation of the download progress of the peer. The
  1914. highest bit corresponds to piece index 0. The set bits indicate the
  1915. piece is available and unset bits indicate the piece is missing. The
  1916. spare bits at the end are set to zero.
  1917. ``amChoking``
  1918. ``true`` if this client is choking the peer. Otherwise ``false``.
  1919. ``peerChoking``
  1920. ``true`` if the peer is choking this client. Otherwise ``false``.
  1921. ``downloadSpeed``
  1922. Download speed (byte/sec) that this client obtains from the peer.
  1923. ``uploadSpeed``
  1924. Upload speed(byte/sec) that this client uploads to the peer.
  1925. ``seeder``
  1926. ``true`` is this client is a seeder. Otherwise ``false``.
  1927. **JSON-RPC Example**
  1928. ::
  1929. >>> import urllib2, json
  1930. >>> from pprint import pprint
  1931. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  1932. ... 'method':'aria2.getPeers',
  1933. ... 'params':['2089b05ecca3d829']})
  1934. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  1935. >>> pprint(json.loads(c.read()))
  1936. {u'id': u'qwer',
  1937. u'jsonrpc': u'2.0',
  1938. u'result': [{u'amChoking': u'true',
  1939. u'bitfield': u'ffffffffffffffffffffffffffffffffffffffff',
  1940. u'downloadSpeed': u'10602',
  1941. u'ip': u'10.0.0.9',
  1942. u'peerChoking': u'false',
  1943. u'peerId': u'aria2%2F1%2E10%2E5%2D%87%2A%EDz%2F%F7%E6',
  1944. u'port': u'6881',
  1945. u'seeder': u'true',
  1946. u'uploadSpeed': u'0'},
  1947. {u'amChoking': u'false',
  1948. u'bitfield': u'ffffeff0fffffffbfffffff9fffffcfff7f4ffff',
  1949. u'downloadSpeed': u'8654',
  1950. u'ip': u'10.0.0.30',
  1951. u'peerChoking': u'false',
  1952. u'peerId': u'bittorrent client758',
  1953. u'port': u'37842',
  1954. u'seeder': u'false',
  1955. u'uploadSpeed': u'6890'}]}
  1956. **XML-RPC Example**
  1957. ::
  1958. >>> import xmlrpclib
  1959. >>> from pprint import pprint
  1960. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  1961. >>> r = s.aria2.getPeers('2089b05ecca3d829')
  1962. >>> pprint(r)
  1963. [{'amChoking': 'true',
  1964. 'bitfield': 'ffffffffffffffffffffffffffffffffffffffff',
  1965. 'downloadSpeed': '10602',
  1966. 'ip': '10.0.0.9',
  1967. 'peerChoking': 'false',
  1968. 'peerId': 'aria2%2F1%2E10%2E5%2D%87%2A%EDz%2F%F7%E6',
  1969. 'port': '6881',
  1970. 'seeder': 'true',
  1971. 'uploadSpeed': '0'},
  1972. {'amChoking': 'false',
  1973. 'bitfield': 'ffffeff0fffffffbfffffff9fffffcfff7f4ffff',
  1974. 'downloadSpeed': '8654',
  1975. 'ip': '10.0.0.30',
  1976. 'peerChoking': 'false',
  1977. 'peerId': 'bittorrent client758',
  1978. 'port': '37842',
  1979. 'seeder': 'false,
  1980. 'uploadSpeed': '6890'}]
  1981. .. function:: aria2.getServers(gid)
  1982. This method returns currently connected HTTP(S)/FTP servers of the download denoted by *gid*. *gid* is of type string. The response
  1983. is of type array and its element is of type struct and it contains
  1984. following keys. The value type is string.
  1985. ``index``
  1986. Index of file. Starting with 1. This is the same order with the
  1987. files in multi-file torrent.
  1988. ``servers``
  1989. The list of struct which contains following keys.
  1990. ``uri``
  1991. URI originally added.
  1992. ``currentUri``
  1993. This is the URI currently used for downloading. If redirection is
  1994. involved, currentUri and uri may differ.
  1995. ``downloadSpeed``
  1996. Download speed (byte/sec)
  1997. **JSON-RPC Example**
  1998. ::
  1999. >>> import urllib2, json
  2000. >>> from pprint import pprint
  2001. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2002. ... 'method':'aria2.getServers',
  2003. ... 'params':['2089b05ecca3d829']})
  2004. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2005. >>> pprint(json.loads(c.read()))
  2006. {u'id': u'qwer',
  2007. u'jsonrpc': u'2.0',
  2008. u'result': [{u'index': u'1',
  2009. u'servers': [{u'currentUri': u'http://example.org/file',
  2010. u'downloadSpeed': u'10467',
  2011. u'uri': u'http://example.org/file'}]}]}
  2012. **XML-RPC Example**
  2013. ::
  2014. >>> import xmlrpclib
  2015. >>> from pprint import pprint
  2016. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2017. >>> r = s.aria2.getServers('2089b05ecca3d829')
  2018. >>> pprint(r)
  2019. [{'index': '1',
  2020. 'servers': [{'currentUri': 'http://example.org/dl/file',
  2021. 'downloadSpeed': '20285',
  2022. 'uri': 'http://example.org/file'}]}]
  2023. .. function:: aria2.tellActive([keys])
  2024. This method returns the list of active downloads. The response is of
  2025. type array and its element is the same struct returned by
  2026. :func:`aria2.tellStatus` method. For *keys* parameter, please refer to
  2027. :func:`aria2.tellStatus` method.
  2028. .. function:: aria2.tellWaiting(offset, num, [keys])
  2029. This method returns the list of waiting download, including paused
  2030. downloads. *offset* is of type integer and specifies the offset from
  2031. the download waiting at the front. *num* is of type integer and
  2032. specifies the number of downloads to be returned. For *keys*
  2033. parameter, please refer to :func:`aria2.tellStatus` method.
  2034. If *offset* is a positive integer, this method returns downloads in the
  2035. range of [*offset*, *offset* + *num*).
  2036. *offset* can be a negative integer. *offset* == -1 points last
  2037. download in the waiting queue and *offset* == -2 points the download
  2038. before the last download, and so on. The downloads in the response are
  2039. in reversed order.
  2040. For example, imagine that three downloads "A","B" and "C" are waiting
  2041. in this order. ``aria2.tellWaiting(0, 1)`` returns
  2042. ``["A"]``. ``aria2.tellWaiting(1, 2)`` returns ``["B", "C"]``.
  2043. ``aria2.tellWaiting(-1, 2)`` returns ``["C", "B"]``.
  2044. The response is of type array and its element is the same struct
  2045. returned by :func:`aria2.tellStatus` method.
  2046. .. function:: aria2.tellStopped(offset, num, [keys])
  2047. This method returns the list of stopped download. *offset* is of type
  2048. integer and specifies the offset from the oldest download. *num* is of
  2049. type integer and specifies the number of downloads to be returned.
  2050. For *keys* parameter, please refer to :func:`aria2.tellStatus` method.
  2051. *offset* and *num* have the same semantics as :func:`aria2.tellWaiting`
  2052. method.
  2053. The response is of type array and its element is the same struct
  2054. returned by :func:`aria2.tellStatus` method.
  2055. .. function:: aria2.changePosition(gid, pos, how)
  2056. This method changes the position of the download denoted by
  2057. *gid*. *pos* is of type integer. *how* is of type string. If *how* is
  2058. ``POS_SET``, it moves the download to a position relative to the
  2059. beginning of the queue. If *how* is ``POS_CUR``, it moves the download
  2060. to a position relative to the current position. If *how* is ``POS_END``,
  2061. it moves the download to a position relative to the end of the
  2062. queue. If the destination position is less than 0 or beyond the end of
  2063. the queue, it moves the download to the beginning or the end of the
  2064. queue respectively. The response is of type integer and it is the
  2065. destination position.
  2066. For example, if GID#2089b05ecca3d829 is placed in position 3,
  2067. ``aria2.changePosition('2089b05ecca3d829', -1, 'POS_CUR')`` will
  2068. change its position to 2. Additional
  2069. ``aria2.changePosition('2089b05ecca3d829', 0, 'POS_SET')`` will
  2070. change its position to 0(the beginning of the queue).
  2071. The following examples move the download GID#2089b05ecca3d829 to the
  2072. front of the waiting queue.
  2073. **JSON-RPC Example**
  2074. ::
  2075. >>> import urllib2, json
  2076. >>> from pprint import pprint
  2077. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2078. ... 'method':'aria2.changePosition',
  2079. ... 'params':['2089b05ecca3d829', 0, 'POS_SET']})
  2080. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2081. >>> pprint(json.loads(c.read()))
  2082. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': 0}
  2083. **XML-RPC Example**
  2084. ::
  2085. >>> import xmlrpclib
  2086. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2087. >>> s.aria2.changePosition('2089b05ecca3d829', 0, 'POS_SET')
  2088. 0
  2089. .. function:: aria2.changeUri(gid, fileIndex, delUris, addUris[, position])
  2090. This method removes URIs in *delUris* from and appends URIs in
  2091. *addUris* to download denoted by *gid*. *delUris* and *addUris* are
  2092. list of string. A download can contain multiple files and URIs are
  2093. attached to each file. *fileIndex* is used to select which file to
  2094. remove/attach given URIs. *fileIndex* is 1-based. *position* is used
  2095. to specify where URIs are inserted in the existing waiting URI
  2096. list. *position* is 0-based. When *position* is omitted, URIs are
  2097. appended to the back of the list. This method first execute removal
  2098. and then addition. *position* is the position after URIs are removed,
  2099. not the position when this method is called. When removing URI, if
  2100. same URIs exist in download, only one of them is removed for each URI
  2101. in *delUris*. In other words, there are three URIs
  2102. ``http://example.org/aria2`` and you want remove them all, you have to
  2103. specify (at least) 3 ``http://example.org/aria2`` in *delUris*. This
  2104. method returns a list which contains 2 integers. The first integer is
  2105. the number of URIs deleted. The second integer is the number of URIs
  2106. added.
  2107. The following examples add 1 URI ``http://example.org/file`` to the
  2108. file whose index is ``1`` and belongs to the download
  2109. GID#2089b05ecca3d829.
  2110. **JSON-RPC Example**
  2111. ::
  2112. >>> import urllib2, json
  2113. >>> from pprint import pprint
  2114. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2115. ... 'method':'aria2.changeUri',
  2116. ... 'params':['2089b05ecca3d829', 1, [],
  2117. ['http://example.org/file']]})
  2118. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2119. >>> pprint(json.loads(c.read()))
  2120. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': [0, 1]}
  2121. **XML-RPC Example**
  2122. ::
  2123. >>> import xmlrpclib
  2124. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2125. >>> s.aria2.changeUri('2089b05ecca3d829', 1, [],
  2126. ['http://example.org/file'])
  2127. [0, 1]
  2128. .. function:: aria2.getOption(gid)
  2129. This method returns options of the download denoted by *gid*. The
  2130. response is of type struct. Its key is the name of option. The value
  2131. type is string. Note that this method does not return options which
  2132. have no default value and have not been set by the command-line
  2133. options, configuration files or RPC methods.
  2134. The following examples get options of the download
  2135. GID#2089b05ecca3d829.
  2136. **JSON-RPC Example**
  2137. ::
  2138. >>> import urllib2, json
  2139. >>> from pprint import pprint
  2140. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2141. ... 'method':'aria2.getOption',
  2142. ... 'params':['2089b05ecca3d829']})
  2143. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2144. >>> pprint(json.loads(c.read()))
  2145. {u'id': u'qwer',
  2146. u'jsonrpc': u'2.0',
  2147. u'result': {u'allow-overwrite': u'false',
  2148. u'allow-piece-length-change': u'false',
  2149. u'always-resume': u'true',
  2150. u'async-dns': u'true',
  2151. ...
  2152. **XML-RPC Example**
  2153. ::
  2154. >>> import xmlrpclib
  2155. >>> from pprint import pprint
  2156. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2157. >>> r = s.aria2.getOption('2089b05ecca3d829')
  2158. >>> pprint(r)
  2159. {'allow-overwrite': 'false',
  2160. 'allow-piece-length-change': 'false',
  2161. 'always-resume': 'true',
  2162. 'async-dns': 'true',
  2163. ....
  2164. .. function:: aria2.changeOption(gid, options)
  2165. This method changes options of the download denoted by *gid*
  2166. dynamically. *gid* is of type string. *options* is of type struct.
  2167. The following options are available for active downloads:
  2168. * :option:`bt-max-peers <--bt-max-peers>`
  2169. * :option:`bt-request-peer-speed-limit <--bt-request-peer-speed-limit>`
  2170. * :option:`bt-remove-unselected-file <--bt-remove-unselected-file>`
  2171. * :option:`force-save <--force-save>`
  2172. * :option:`max-download-limit <--max-download-limit>`
  2173. * :option:`max-upload-limit <-u>`
  2174. For waiting or paused downloads, in addition to the above options,
  2175. options listed in `Input File`_ subsection are available,
  2176. except for following options:
  2177. :option:`dry-run <--dry-run>`,
  2178. :option:`metalink-base-uri <--metalink-base-uri>`,
  2179. :option:`parameterized-uri <-P>`,
  2180. :option:`pause <--pause>`,
  2181. :option:`piece-length <--piece-length>` and
  2182. :option:`rpc-save-upload-metadata <--rpc-save-upload-metadata>` option.
  2183. This method returns ``OK`` for success.
  2184. The following examples set :option:`max-download-limit
  2185. <--max-download-limit>` option to ``20K`` for the download
  2186. GID#2089b05ecca3d829.
  2187. **JSON-RPC Example**
  2188. ::
  2189. >>> import urllib2, json
  2190. >>> from pprint import pprint
  2191. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2192. ... 'method':'aria2.changeOption',
  2193. ... 'params':['2089b05ecca3d829',
  2194. ... {'max-download-limit':'10K'}]})
  2195. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2196. >>> pprint(json.loads(c.read()))
  2197. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'OK'}
  2198. **XML-RPC Example**
  2199. ::
  2200. >>> import xmlrpclib
  2201. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2202. >>> s.aria2.changeOption('2089b05ecca3d829', {'max-download-limit':'20K'})
  2203. 'OK'
  2204. .. function:: aria2.getGlobalOption()
  2205. This method returns global options. The response is of type
  2206. struct. Its key is the name of option. The value type is string.
  2207. Note that this method does not return options which have no default
  2208. value and have not been set by the command-line options, configuration
  2209. files or RPC methods. Because global options are used as a template
  2210. for the options of newly added download, the response contains keys
  2211. returned by :func:`aria2.getOption` method.
  2212. .. function:: aria2.changeGlobalOption(options)
  2213. This method changes global options dynamically. *options* is of type
  2214. struct.
  2215. The following options are available:
  2216. * :option:`bt-max-open-files <--bt-max-open-files>`
  2217. * :option:`download-result <--download-result>`
  2218. * :option:`log <-l>`
  2219. * :option:`log-level <--log-level>`
  2220. * :option:`max-concurrent-downloads <-j>`
  2221. * :option:`max-download-result <--max-download-result>`
  2222. * :option:`max-overall-download-limit <--max-overall-download-limit>`
  2223. * :option:`max-overall-upload-limit <--max-overall-upload-limit>`
  2224. * :option:`save-cookies <--save-cookies>`
  2225. * :option:`save-session <--save-session>`
  2226. * :option:`server-stat-of <--server-stat-of>`
  2227. In addition to them, options listed in `Input File`_ subsection
  2228. are available, except for following options:
  2229. :option:`checksum <--checksum>`,
  2230. :option:`index-out <-O>`,
  2231. :option:`out <-o>`,
  2232. :option:`pause <--pause>` and
  2233. :option:`select-file <--select-file>`.
  2234. Using :option:`log <-l>` option, you can dynamically start logging or
  2235. change log file. To stop logging, give empty string("") as a parameter
  2236. value. Note that log file is always opened in append mode. This method
  2237. returns ``OK`` for success.
  2238. .. function:: aria2.getGlobalStat()
  2239. This method returns global statistics such as overall download and
  2240. upload speed. The response is of type struct and contains following
  2241. keys. The value type is string.
  2242. ``downloadSpeed``
  2243. Overall download speed (byte/sec).
  2244. ``uploadSpeed``
  2245. Overall upload speed(byte/sec).
  2246. ``numActive``
  2247. The number of active downloads.
  2248. ``numWaiting``
  2249. The number of waiting downloads.
  2250. ``numStopped``
  2251. The number of stopped downloads.
  2252. **JSON-RPC Example**
  2253. ::
  2254. >>> import urllib2, json
  2255. >>> from pprint import pprint
  2256. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2257. ... 'method':'aria2.getGlobalStat'})
  2258. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2259. >>> pprint(json.loads(c.read()))
  2260. {u'id': u'qwer',
  2261. u'jsonrpc': u'2.0',
  2262. u'result': {u'downloadSpeed': u'21846',
  2263. u'numActive': u'2',
  2264. u'numStopped': u'0',
  2265. u'numWaiting': u'0',
  2266. u'uploadSpeed': u'0'}}
  2267. **XML-RPC Example**
  2268. ::
  2269. >>> import xmlrpclib
  2270. >>> from pprint import pprint
  2271. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2272. >>> r = s.aria2.getGlobalStat()
  2273. >>> pprint(r)
  2274. {'downloadSpeed': '23136',
  2275. 'numActive': '2',
  2276. 'numStopped': '0',
  2277. 'numWaiting': '0',
  2278. 'uploadSpeed': '0'}
  2279. .. function:: aria2.purgeDownloadResult()
  2280. This method purges completed/error/removed downloads to free memory.
  2281. This method returns ``OK``.
  2282. .. function:: aria2.removeDownloadResult(gid)
  2283. This method removes completed/error/removed download denoted by *gid*
  2284. from memory. This method returns ``OK`` for success.
  2285. The following examples remove the download result of the download
  2286. GID#2089b05ecca3d829.
  2287. **JSON-RPC Example**
  2288. ::
  2289. >>> import urllib2, json
  2290. >>> from pprint import pprint
  2291. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2292. ... 'method':'aria2.removeDownloadResult',
  2293. ... 'params':['2089b05ecca3d829']})
  2294. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2295. >>> pprint(json.loads(c.read()))
  2296. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'OK'}
  2297. **XML-RPC Example**
  2298. ::
  2299. >>> import xmlrpclib
  2300. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2301. >>> s.aria2.removeDownloadResult('2089b05ecca3d829')
  2302. 'OK'
  2303. .. function:: aria2.getVersion()
  2304. This method returns version of the program and the list of enabled
  2305. features. The response is of type struct and contains following keys.
  2306. ``version``
  2307. Version number of the program in string.
  2308. ``enabledFeatures``
  2309. List of enabled features. Each feature name is of type string.
  2310. **JSON-RPC Example**
  2311. ::
  2312. >>> import urllib2, json
  2313. >>> from pprint import pprint
  2314. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2315. ... 'method':'aria2.getVersion'})
  2316. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2317. >>> pprint(json.loads(c.read()))
  2318. {u'id': u'qwer',
  2319. u'jsonrpc': u'2.0',
  2320. u'result': {u'enabledFeatures': [u'Async DNS',
  2321. u'BitTorrent',
  2322. u'Firefox3 Cookie',
  2323. u'GZip',
  2324. u'HTTPS',
  2325. u'Message Digest',
  2326. u'Metalink',
  2327. u'XML-RPC'],
  2328. u'version': u'1.11.0'}}
  2329. **XML-RPC Example**
  2330. ::
  2331. >>> import xmlrpclib
  2332. >>> from pprint import pprint
  2333. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2334. >>> r = s.aria2.getVersion()
  2335. >>> pprint(r)
  2336. {'enabledFeatures': ['Async DNS',
  2337. 'BitTorrent',
  2338. 'Firefox3 Cookie',
  2339. 'GZip',
  2340. 'HTTPS',
  2341. 'Message Digest',
  2342. 'Metalink',
  2343. 'XML-RPC'],
  2344. 'version': '1.11.0'}
  2345. .. function:: aria2.getSessionInfo()
  2346. This method returns session information.
  2347. The response is of type struct and contains following key.
  2348. ``sessionId``
  2349. Session ID, which is generated each time when aria2 is invoked.
  2350. **JSON-RPC Example**
  2351. ::
  2352. >>> import urllib2, json
  2353. >>> from pprint import pprint
  2354. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2355. ... 'method':'aria2.getSessionInfo'})
  2356. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2357. >>> pprint(json.loads(c.read()))
  2358. {u'id': u'qwer',
  2359. u'jsonrpc': u'2.0',
  2360. u'result': {u'sessionId': u'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}}
  2361. **XML-RPC Example**
  2362. ::
  2363. >>> import xmlrpclib
  2364. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2365. >>> s.aria2.getSessionInfo()
  2366. {'sessionId': 'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}
  2367. .. function:: aria2.shutdown()
  2368. This method shutdowns aria2. This method returns ``OK``.
  2369. .. function:: aria2.forceShutdown()
  2370. This method shutdowns :func:`aria2. This method behaves like aria2.shutdown`
  2371. except that any actions which takes time such as contacting BitTorrent
  2372. tracker are skipped. This method returns ``OK``.
  2373. .. function:: system.multicall(methods)
  2374. This methods encapsulates multiple method calls in a single request.
  2375. *methods* is of type array and its element is struct. The struct
  2376. contains two keys: ``methodName`` and ``params``. ``methodName`` is the
  2377. method name to call and ``params`` is array containing parameters to the
  2378. method. This method returns array of responses. The element of array
  2379. will either be a one-item array containing the return value of each
  2380. method call or struct of fault element if an encapsulated method call
  2381. fails.
  2382. In the following examples, we add 2 downloads. First one is
  2383. ``http://example.org/file`` and second one is ``file.torrent``.
  2384. **JSON-RPC Example**
  2385. ::
  2386. >>> import urllib2, json, base64
  2387. >>> from pprint import pprint
  2388. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2389. ... 'method':'system.multicall',
  2390. ... 'params':[[{'methodName':'aria2.addUri',
  2391. ... 'params':[['http://example.org']]},
  2392. ... {'methodName':'aria2.addTorrent',
  2393. ... 'params':[base64.b64encode(open('file.torrent').read())]}]]})
  2394. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2395. >>> pprint(json.loads(c.read()))
  2396. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': [[u'2089b05ecca3d829'], [u'd2703803b52216d1']]}
  2397. JSON-RPC also supports Batch request described in JSON-RPC 2.0 Specification::
  2398. >>> jsonreq = json.dumps([{'jsonrpc':'2.0', 'id':'qwer',
  2399. ... 'method':'aria2.addUri',
  2400. ... 'params':[['http://example.org']]},
  2401. ... {'jsonrpc':'2.0', 'id':'asdf',
  2402. ... 'method':'aria2.addTorrent',
  2403. ... 'params':[base64.b64encode(open('file.torrent').read())]}])
  2404. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2405. >>> pprint(json.loads(c.read()))
  2406. [{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'2089b05ecca3d829'},
  2407. {u'id': u'asdf', u'jsonrpc': u'2.0', u'result': u'd2703803b52216d1'}]
  2408. **XML-RPC Example**
  2409. ::
  2410. >>> import xmlrpclib
  2411. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2412. >>> mc = xmlrpclib.MultiCall(s)
  2413. >>> mc.aria2.addUri(['http://example.org/file'])
  2414. >>> mc.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
  2415. >>> r = mc()
  2416. >>> tuple(r)
  2417. ('2089b05ecca3d829', 'd2703803b52216d1')
  2418. Error Handling
  2419. ~~~~~~~~~~~~~~
  2420. In JSON-RPC, aria2 returns JSON object which contains error code in
  2421. code and the error message in message.
  2422. In XML-RPC, aria2 returns faultCode=1 and the error message in
  2423. faultString.
  2424. .. _rpc_options:
  2425. Options
  2426. ~~~~~~~
  2427. Same options for :option:`--input-file <-i>` list are available. See `Input File`_ subsection for complete list of options.
  2428. In the option struct, name element is option name(without preceding
  2429. ``--``) and value element is argument as string.
  2430. JSON-RPC Example
  2431. ^^^^^^^^^^^^^^^^
  2432. ::
  2433. {'split':'1', 'http-proxy':'http://proxy/'}
  2434. XML-RPC Example
  2435. ^^^^^^^^^^^^^^^
  2436. .. code-block:: xml
  2437. <struct>
  2438. <member>
  2439. <name>split</name>
  2440. <value><string>1</string></value>
  2441. </member>
  2442. <member>
  2443. <name>http-proxy</name>
  2444. <value><string>http://proxy/</string></value>
  2445. </member>
  2446. </struct>
  2447. :option:`header <--header>` and :option:`index-out <-O>`
  2448. option are allowed multiple times in
  2449. command-line. Since name should be unique in struct(many XML-RPC
  2450. library implementation uses hash or dict for struct), single string is
  2451. not enough. To overcome this situation, they can take array as value
  2452. as well as string.
  2453. JSON-RPC Example
  2454. ^^^^^^^^^^^^^^^^
  2455. ::
  2456. {'header':['Accept-Language: ja', 'Accept-Charset: utf-8']}
  2457. XML-RPC Example
  2458. ^^^^^^^^^^^^^^^
  2459. .. code-block:: xml
  2460. <struct>
  2461. <member>
  2462. <name>header</name>
  2463. <value>
  2464. <array>
  2465. <data>
  2466. <value><string>Accept-Language: ja</string></value>
  2467. <value><string>Accept-Charset: utf-8</string></value>
  2468. </data>
  2469. </array>
  2470. </value>
  2471. </member>
  2472. </struct>
  2473. Following example adds a download with 2 options: dir and header.
  2474. header option has 2 values, so it uses a list::
  2475. >>> import xmlrpclib
  2476. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2477. >>> opts = dict(dir='/tmp',
  2478. ... header=['Accept-Language: ja',
  2479. ... 'Accept-Charset: utf-8'])
  2480. >>> s.aria2.addUri(['http://example.org/file'], opts)
  2481. '1'
  2482. JSON-RPC using HTTP GET
  2483. ~~~~~~~~~~~~~~~~~~~~~~~
  2484. The JSON-RPC interface also supports request via HTTP GET.
  2485. The encoding scheme in GET parameters is based on JSON-RPC over HTTP Specification [2008-1-15(RC1)].
  2486. The encoding of GET parameters are follows::
  2487. /jsonrpc?method=METHOD_NAME&id=ID&params=BASE64_ENCODED_PARAMS
  2488. The ``method`` and ``id`` are always treated as JSON string and their
  2489. encoding must be UTF-8.
  2490. For example, The encoded string of
  2491. ``aria2.tellStatus('2089b05ecca3d829')`` with ``id='foo'`` looks like
  2492. this::
  2493. /jsonrpc?method=aria2.tellStatus&id=foo&params=WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D
  2494. The ``params`` parameter is Base64-encoded JSON array which usually
  2495. appears in ``params`` attribute in JSON-RPC request object. In the
  2496. above example, the params is ``["2089b05ecca3d829"]``, therefore::
  2497. ["2089b05ecca3d829"] --(Base64)--> WyIyMDg5YjA1ZWNjYTNkODI5Il0=
  2498. --(Percent Encode)--> WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D
  2499. The JSON-RPC interface supports JSONP. You can specify the callback
  2500. function in ``jsoncallback`` parameter::
  2501. /jsonrpc?method=aria2.tellStatus&id=foo&params=WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D&jsoncallback=cb
  2502. For Batch request, ``method`` and ``id`` parameter must not be specified.
  2503. Whole request must be specified in ``params`` parameter. For example,
  2504. Batch request::
  2505. [{'jsonrpc':'2.0', 'id':'qwer', 'method':'aria2.getVersion'},
  2506. {'jsonrpc':'2.0', 'id':'asdf', 'method':'aria2.tellActive'}]
  2507. will be encoded like this::
  2508. /jsonrpc?params=W3sianNvbnJwYyI6ICIyLjAiLCAiaWQiOiAicXdlciIsICJtZXRob2QiOiAiYXJpYTIuZ2V0VmVyc2lvbiJ9LCB7Impzb25ycGMiOiAiMi4wIiwgImlkIjogImFzZGYiLCAibWV0aG9kIjogImFyaWEyLnRlbGxBY3RpdmUifV0%3D
  2509. JSON-RPC over WebSocket
  2510. ~~~~~~~~~~~~~~~~~~~~~~~
  2511. JSON-RPC over WebSocket uses same method signatures and response
  2512. format with JSON-RPC over HTTP. The supported WebSocket version is 13
  2513. which is detailed in :rfc:`6455`.
  2514. To send a RPC request to the RPC server, send serialized JSON string
  2515. in Text frame. The response from the RPC server is delivered also in
  2516. Text frame.
  2517. The RPC server will send the notification to the client. The
  2518. notification is unidirectional, therefore the client which received
  2519. the notification must not respond to it. The method signature of
  2520. notification is much like a normal method request but lacks id
  2521. key. The value associated by the params key is the data which this
  2522. notification carries. The format of this value varies depending on the
  2523. notification method. Following notification methods are defined.
  2524. .. function:: aria2.onDownloadStart(event)
  2525. This notification will be sent if a download is started.
  2526. The *event* is of type struct and it contains following keys.
  2527. The value type is string.
  2528. ``gid``
  2529. GID of the download.
  2530. .. function:: aria2.onDownloadPause(event)
  2531. This notification will be sent if a download is paused. The *event*
  2532. is the same struct of the *event* argument of
  2533. :func:`aria2.onDownloadStart` method.
  2534. .. function:: aria2.onDownloadStop(event)
  2535. This notification will be sent if a download is stopped by the user.
  2536. The *event* is the same struct of the *event* argument of
  2537. :func:`aria2.onDownloadStart` method.
  2538. .. function:: aria2.onDownloadComplete(event)
  2539. This notification will be sent if a download is completed. In
  2540. BitTorrent downloads, this notification is sent when the download is
  2541. completed and seeding is over. The *event* is the same struct of the
  2542. *event* argument of
  2543. :func:`aria2.onDownloadStart` method.
  2544. .. function:: aria2.onDownloadError(event)
  2545. This notification will be sent if a download is stopped due to error.
  2546. The *event* is the same struct of the *event* argument of
  2547. :func:`aria2.onDownloadStart` method.
  2548. .. function:: aria2.onBtDownloadComplete(event)
  2549. This notification will be sent if a download is completed in
  2550. BitTorrent (but seeding may not be over). The *event* is the same struct
  2551. of the *event* argument of
  2552. :func:`aria2.onDownloadStart` method.
  2553. Sample XML-RPC Client Code
  2554. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  2555. The following Ruby script adds ``http://localhost/aria2.tar.bz2`` to
  2556. aria2c operated on localhost with option :option:`--dir=/downloads <-d>` and
  2557. prints its reponse:
  2558. .. code-block:: ruby
  2559. #!/usr/bin/env ruby
  2560. require 'xmlrpc/client'
  2561. require 'pp'
  2562. client=XMLRPC::Client.new2("http://localhost:6800/rpc")
  2563. options={ "dir" => "/downloads" }
  2564. result=client.call("aria2.addUri", [ "http://localhost/aria2.tar.bz2" ], options)
  2565. pp result
  2566. If you are a Python lover, you can use xmlrpclib(for Python3.x, use
  2567. xmlrpc.client instead) to interact with aria2::
  2568. import xmlrpclib
  2569. from pprint import pprint
  2570. s = xmlrpclib.ServerProxy("http://localhost:6800/rpc")
  2571. r = s.aria2.addUri(["http://localhost/aria2.tar.bz2"], {"dir":"/downloads"})
  2572. pprint(r)
  2573. MISC
  2574. ----
  2575. Console Readout
  2576. ~~~~~~~~~~~~~~~
  2577. While downloading files, aria2 prints the console readout to tell the
  2578. progress of the downloads. The console readout is like this::
  2579. [#2089b0 400.0KiB/33.2MiB(1%) CN:1 DL:115.7KiB ETA:4m51s]
  2580. This section describes what these numbers and strings mean.
  2581. ``#NNNNNN``
  2582. The first 6 characters of GID in hex string. GID is an unique ID for
  2583. each download.
  2584. ``X/Y(Z%)``
  2585. Completed length, the total file length and its ratio. If
  2586. :option:`--select-file` is used, this is the sum of selected file.
  2587. ``SEED``
  2588. Share ratio. The client is now seeding. After BitTorrent download
  2589. finished, size information is replaced with this.
  2590. ``CN``
  2591. The number of connections the client has established.
  2592. ``SD``
  2593. The number of seeders the client is now connecting to.
  2594. ``DL``
  2595. Download speed (bytes per second).
  2596. ``UL``
  2597. Upload speed (bytes per second) and the number of uploaded bytes.
  2598. ``ETA``
  2599. Expected time to finish.
  2600. When more than 1 download are going on, some of the information
  2601. described above will be omitted in order to show several download
  2602. information. And the overall download and upload speed are shown at
  2603. the beginning of the line.
  2604. When aria2 is allocating file space or validating checksum, it
  2605. additionally prints the their progress:
  2606. FileAlloc
  2607. GID, allocated length and total length in bytes.
  2608. Checksum
  2609. GID, validated length and total length in bytes.
  2610. EXAMPLE
  2611. -------
  2612. HTTP/FTP Segmented Download
  2613. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2614. Download a file
  2615. ^^^^^^^^^^^^^^^
  2616. .. code-block:: console
  2617. $ aria2c "http://host/file.zip"
  2618. .. note::
  2619. To stop a download, press :kbd:`Ctrl-C`. You can resume the transfer by running aria2c with the same argument in the same directory. You can change URIs as long as they are pointing to the same file.
  2620. Download a file from 2 different HTTP servers
  2621. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2622. .. code-block:: console
  2623. $ aria2c "http://host/file.zip" "http://mirror/file.zip"
  2624. Download a file from 1 host using 2 connections
  2625. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2626. .. code-block:: console
  2627. $ aria2c -x2 -k1M "http://host/file.zip"
  2628. Download a file from HTTP and FTP servers
  2629. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2630. .. code-block:: console
  2631. $ aria2c "http://host1/file.zip" "ftp://host2/file.zip"
  2632. Download files listed in a text file concurrently
  2633. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2634. .. code-block:: console
  2635. $ aria2c -ifiles.txt -j2
  2636. .. note::
  2637. -j option specifies the number of parallel downloads.
  2638. Using proxy
  2639. ^^^^^^^^^^^
  2640. For HTTP:
  2641. .. code-block:: console
  2642. $ aria2c --http-proxy="http://proxy:8080" "http://host/file"
  2643. .. code-block:: console
  2644. $ aria2c --http-proxy="http://proxy:8080" --no-proxy="localhost,127.0.0.1,192.168.0.0/16" "http://host/file"
  2645. For FTP:
  2646. .. code-block:: console
  2647. $ aria2c --ftp-proxy="http://proxy:8080" "ftp://host/file"
  2648. .. note::
  2649. See :option:`--http-proxy`, :option:`--https-proxy`, :option:`--ftp-proxy`, :option:`--all-proxy` and
  2650. :option:`--no-proxy` for details. You can specify proxy in the environment
  2651. variables. See `ENVIRONMENT`_ section.
  2652. Proxy with authorization
  2653. ^^^^^^^^^^^^^^^^^^^^^^^^
  2654. .. code-block:: console
  2655. $ aria2c --http-proxy="http://username:password@proxy:8080" "http://host/file"
  2656. .. code-block:: console
  2657. $ aria2c --http-proxy="http://proxy:8080" --http-proxy-user="username" --http-proxy-passwd="password" "http://host/file"
  2658. Metalink Download
  2659. ~~~~~~~~~~~~~~~~~
  2660. Download files with remote Metalink
  2661. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2662. .. code-block:: console
  2663. $ aria2c --follow-metalink=mem "http://host/file.metalink"
  2664. Download using a local metalink file
  2665. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2666. .. code-block:: console
  2667. $ aria2c -p --lowest-speed-limit=4000 file.metalink
  2668. .. note::
  2669. To stop a download, press :kbd:`Ctrl-C`.
  2670. You can resume the transfer by running aria2c with the same argument in the same
  2671. directory.
  2672. Download several local metalink files
  2673. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2674. .. code-block:: console
  2675. $ aria2c -j2 file1.metalink file2.metalink
  2676. Download only selected files using index
  2677. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2678. .. code-block:: console
  2679. $ aria2c --select-file=1-4,8 file.metalink
  2680. .. note::
  2681. The index is printed to the console using -S option.
  2682. Download a file using a local metalink file with user preference
  2683. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2684. .. code-block:: console
  2685. $ aria2c --metalink-location=jp,us --metalink-version=1.1 --metalink-language=en-US file.metalink
  2686. BitTorrent Download
  2687. ~~~~~~~~~~~~~~~~~~~
  2688. Download files from remote BitTorrent file
  2689. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2690. .. code-block:: console
  2691. $ aria2c --follow-torrent=mem "http://host/file.torrent"
  2692. Download using a local torrent file
  2693. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2694. .. code-block:: console
  2695. $ aria2c --max-upload-limit=40K file.torrent
  2696. .. note::
  2697. --max-upload-limit specifies the max of upload rate.
  2698. .. note::
  2699. To stop a download, press :kbd:`Ctrl-C`. You can resume the transfer by running aria2c with the same argument in the same directory.
  2700. Download using BitTorrent Magnet URI
  2701. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2702. .. code-block:: console
  2703. $ aria2c "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C&dn=aria2"
  2704. .. note::
  2705. Don't forget to quote BitTorrent Magnet URI which includes ``&``
  2706. character with single(``'``) or double(``"``) quotation.
  2707. Download 2 torrents
  2708. ^^^^^^^^^^^^^^^^^^^
  2709. .. code-block:: console
  2710. $ aria2c -j2 file1.torrent file2.torrent
  2711. Download a file using torrent and HTTP/FTP server
  2712. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2713. .. code-block:: console
  2714. $ aria2c -Ttest.torrent "http://host1/file" "ftp://host2/file"
  2715. .. note::
  2716. Downloading multi file torrent with HTTP/FTP is not supported.
  2717. Download only selected files using index(usually called "selectable download")
  2718. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2719. .. code-block:: console
  2720. $ aria2c --select-file=1-4,8 file.torrent
  2721. .. note::
  2722. The index is printed to the console using -S option.
  2723. Download .torrent file, but do not download its contents
  2724. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2725. .. code-block:: console
  2726. $ aria2c --follow-torrent=false "http://host/file.torrent"
  2727. Specify output filename
  2728. ^^^^^^^^^^^^^^^^^^^^^^^
  2729. To specify output filename for BitTorrent downloads, you need to know
  2730. the index of file in torrent file using :option:`--show-files <-S>` option. For example, the
  2731. output looks like this::
  2732. idx|path/length
  2733. ===+======================
  2734. 1|dist/base-2.6.18.iso
  2735. |99.9MiB
  2736. ---+----------------------
  2737. 2|dist/driver-2.6.18.iso
  2738. |169.0MiB
  2739. ---+----------------------
  2740. To save 'dist/base-2.6.18.iso' in '/tmp/mydir/base.iso' and
  2741. 'dist/driver-2.6.18.iso' in '/tmp/dir/driver.iso', use the following
  2742. command:
  2743. .. code-block:: console
  2744. $ aria2c --dir=/tmp --index-out=1=mydir/base.iso --index-out=2=dir/driver.iso file.torrent
  2745. Change the listening port for incoming peer
  2746. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2747. .. code-block:: console
  2748. $ aria2c --listen-port=7000-7001,8000 file.torrent
  2749. .. note::
  2750. Since aria2 doesn't configure firewall or router for port forwarding, it's up
  2751. to you to do it manually.
  2752. Specify the condition to stop program after torrent download finished
  2753. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2754. .. code-block:: console
  2755. $ aria2c --seed-time=120 --seed-ratio=1.0 file.torrent
  2756. .. note::
  2757. In the above example, the program exits when the 120 minutes has elapsed since download completed or seed ratio reaches 1.0.
  2758. Throttle upload speed
  2759. ^^^^^^^^^^^^^^^^^^^^^
  2760. .. code-block:: console
  2761. $ aria2c --max-upload-limit=100K file.torrent
  2762. Enable IPv4 DHT
  2763. ^^^^^^^^^^^^^^^
  2764. .. code-block:: console
  2765. $ aria2c --enable-dht --dht-listen-port=6881 file.torrent
  2766. .. note::
  2767. DHT uses udp port. Since aria2 doesn't configure firewall or router for port
  2768. forwarding, it's up to you to do it manually.
  2769. Enable IPv6 DHT
  2770. ^^^^^^^^^^^^^^^
  2771. .. code-block:: console
  2772. $ aria2c --enable-dht6 --dht-listen-port=6881 --dht-listen-addr6=YOUR_GLOBAL_UNICAST_IPV6_ADDR
  2773. .. note::
  2774. aria2 shares same port between IPv4 and IPv6 DHT.
  2775. Add and remove tracker URI
  2776. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  2777. Removes all tracker announce URIs described in file.torrent and use
  2778. ``http://tracker1/announce`` and ``http://tracker2/announce`` instead:
  2779. .. code-block:: console
  2780. $ aria2c --bt-exclude-tracker="*" --bt-tracker="http://tracker1/announce,http://tracker2/announce" file.torrent
  2781. More advanced HTTP features
  2782. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2783. Load cookies
  2784. ^^^^^^^^^^^^
  2785. .. code-block:: console
  2786. $ aria2c --load-cookies=cookies.txt "http://host/file.zip"
  2787. .. note::
  2788. You can use Firefox/Mozilla/Chromium's cookie file without modification.
  2789. Resume download started by web browsers or another programs
  2790. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2791. .. code-block:: console
  2792. $ aria2c -c -s2 "http://host/partiallydownloadedfile.zip"
  2793. Client certificate authorization for SSL/TLS
  2794. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2795. Specify a PKCS12 file as follows:
  2796. .. code-block:: console
  2797. $ aria2c --certificate=/path/to/mycert.p12
  2798. .. note::
  2799. The file specified in :option:`--certificate` must be contain one PKCS12 encoded
  2800. certificate and key. The password must be blank.
  2801. Alternatively, if PEM files are supported, use a command like the following:
  2802. .. code-block:: console
  2803. $ aria2c --certificate=/path/to/mycert.pem --private-key=/path/to/mykey.pem https://host/file
  2804. .. note::
  2805. The file specified in :option:`--private-key` must be decrypted. The behavior when
  2806. encrypted one is given is undefined.
  2807. Verify peer in SSL/TLS using given CA certificates
  2808. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2809. .. code-block:: console
  2810. $ aria2c --ca-certificate=/path/to/ca-certificates.crt --check-certificate https://host/file
  2811. RPC
  2812. ~~~
  2813. Encrypt RPC transport by SSL/TLS
  2814. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2815. Specify server PKC12 file:
  2816. .. code-block:: console
  2817. $ aria2c --enable-rpc --rpc-certificate=/path/to/server.p12 --rpc-secure
  2818. .. note::
  2819. The file specified in :option:`--rpc-certificate` must be contain one PKCS12 encoded
  2820. certificate and key. The password must be blank.
  2821. Alternatively when PEM files are supported, specify the server certificate file and private key file as follows:
  2822. .. code-block:: console
  2823. $ aria2c --enable-rpc --rpc-certificate=/path/to/server.crt --rpc-private-key=/path/to/server.key --rpc-secure
  2824. And more advanced features
  2825. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  2826. Throttle download speed
  2827. ^^^^^^^^^^^^^^^^^^^^^^^
  2828. .. code-block:: console
  2829. $ aria2c --max-download-limit=100K file.metalink
  2830. Repair a damaged download
  2831. ^^^^^^^^^^^^^^^^^^^^^^^^^
  2832. .. code-block:: console
  2833. $ aria2c -V file.metalink
  2834. .. note::
  2835. Repairing damaged downloads can be done efficiently when used with
  2836. BitTorrent or Metalink with chunk checksums.
  2837. Drop connection if download speed is lower than specified value
  2838. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2839. .. code-block:: console
  2840. $ aria2c --lowest-speed-limit=10K file.metalink
  2841. Parameterized URI support
  2842. ^^^^^^^^^^^^^^^^^^^^^^^^^
  2843. You can specify set of parts:
  2844. .. code-block:: console
  2845. $ aria2c -P "http://{host1,host2,host3}/file.iso"
  2846. You can specify numeric sequence:
  2847. .. code-block:: console
  2848. $ aria2c -Z -P "http://host/image[000-100].png"
  2849. .. note::
  2850. -Z option is required if the all URIs don't point to the same file, such as the above example.
  2851. You can specify step counter:
  2852. .. code-block:: console
  2853. $ aria2c -Z -P "http://host/image[A-Z:2].png"
  2854. Verify checksum
  2855. ^^^^^^^^^^^^^^^
  2856. .. code-block:: console
  2857. $ aria2c --checksum=sha-1=0192ba11326fe2298c8cb4de616f4d4140213837 http://example.org/file
  2858. Parallel downloads of arbitrary number of URI,metalink,torrent
  2859. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2860. .. code-block:: console
  2861. $ aria2c -j3 -Z "http://host/file1" file2.torrent file3.metalink
  2862. BitTorrent Encryption
  2863. ^^^^^^^^^^^^^^^^^^^^^
  2864. Encrypt whole payload using ARC4:
  2865. .. code-block:: console
  2866. $ aria2c --bt-min-crypto-level=arc4 --bt-require-crypto=true file.torrent
  2867. SEE ALSO
  2868. --------
  2869. Project Web Site: http://aria2.sourceforge.net/
  2870. aria2 Wiki: http://sourceforge.net/apps/trac/aria2/wiki
  2871. Metalink Homepage: http://www.metalinker.org/
  2872. The Metalink Download Description Format: :rfc:`5854`
  2873. COPYRIGHT
  2874. ---------
  2875. Copyright (C) 2006, 2013 Tatsuhiro Tsujikawa
  2876. This program is free software; you can redistribute it and/or modify
  2877. it under the terms of the GNU General Public License as published by
  2878. the Free Software Foundation; either version 2 of the License, or
  2879. (at your option) any later version.
  2880. This program is distributed in the hope that it will be useful,
  2881. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2882. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2883. GNU General Public License for more details.
  2884. You should have received a copy of the GNU General Public License
  2885. along with this program; if not, write to the Free Software
  2886. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2887. In addition, as a special exception, the copyright holders give
  2888. permission to link the code of portions of this program with the
  2889. OpenSSL library under certain conditions as described in each
  2890. individual source file, and distribute linked combinations
  2891. including the two.
  2892. You must obey the GNU General Public License in all respects
  2893. for all of the code used other than OpenSSL. If you modify
  2894. file(s) with this exception, you may extend this exception to your
  2895. version of the file(s), but you are not obligated to do so. If you
  2896. do not wish to do so, delete this exception statement from your
  2897. version. If you delete this exception statement from all source
  2898. files in the program, then also delete it here.