aria2c.rst 134 KB

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