aria2c.rst 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941
  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 each BitTorrent download.
  444. Default: ``100``
  445. .. option:: --bt-max-peers=<NUM>
  446. Specify the maximum number of peers per torrent. ``0`` means
  447. unlimited. See also :option:`--bt-request-peer-speed-limit` option.
  448. Default: ``55``
  449. .. option:: --bt-metadata-only[=true|false]
  450. Download metadata only. The file(s) described in metadata will not
  451. be downloaded. This option has effect only when BitTorrent Magnet
  452. URI is used. See also :option:`--bt-save-metadata` option. Default: ``false``
  453. .. option:: --bt-min-crypto-level=plain|arc4
  454. Set minimum level of encryption method.
  455. If several encryption methods are provided by a peer, aria2 chooses the lowest
  456. one which satisfies the given level.
  457. Default: ``plain``
  458. .. option:: --bt-prioritize-piece=head[=<SIZE>],tail[=<SIZE>]
  459. Try to download first and last pieces of each file first. This is
  460. useful for previewing files. The argument can contain 2 keywords:
  461. ``head`` and ``tail``. To include both keywords, they must be separated
  462. by comma. These keywords can take one parameter, SIZE. For example,
  463. if ``head=<SIZE>`` is specified, pieces in the range of first SIZE bytes
  464. of each file get higher priority. ``tail=<SIZE>`` means the range of
  465. last SIZE bytes of each file. SIZE can include ``K`` or ``M`` (1K = 1024,
  466. 1M = 1024K). If SIZE is omitted, SIZE=1M is used.
  467. .. option:: --bt-remove-unselected-file[=true|false]
  468. Removes the unselected files when download is completed in
  469. BitTorrent. To select files, use
  470. :option:`--select-file` option. If it is
  471. not used, all files are assumed to be selected. Please use this
  472. option with care because it will actually remove files from your
  473. disk.
  474. Default: ``false``
  475. .. option:: --bt-require-crypto[=true|false]
  476. If true is given, aria2 doesn't accept and establish connection with legacy
  477. BitTorrent handshake(\19BitTorrent protocol).
  478. Thus aria2 always uses Obfuscation handshake.
  479. Default: ``false``
  480. .. option:: --bt-request-peer-speed-limit=<SPEED>
  481. If the whole download speed of every torrent is lower than SPEED,
  482. aria2 temporarily increases the number of peers to try for more
  483. download speed. Configuring this option with your preferred download
  484. speed can increase your download speed in some cases.
  485. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  486. Default: ``50K``
  487. .. option:: --bt-save-metadata[=true|false]
  488. Save metadata as ".torrent" file. This option has effect only when
  489. BitTorrent Magnet URI is used. The filename is hex encoded info
  490. hash with suffix ".torrent". The directory to be saved is the same
  491. directory where download file is saved. If the same file already
  492. exists, metadata is not saved. See also :option:`--bt-metadata-only`
  493. option. Default: ``false``
  494. .. option:: --bt-seed-unverified[=true|false]
  495. Seed previously downloaded files without verifying piece hashes.
  496. Default: ``false``
  497. .. option:: --bt-stop-timeout=<SEC>
  498. Stop BitTorrent download if download speed is 0 in consecutive SEC
  499. seconds. If ``0`` is given, this feature is disabled. Default: ``0``
  500. .. option:: --bt-tracker=<URI>[,...]
  501. Comma separated list of additional BitTorrent tracker's announce
  502. URI. These URIs are not affected by :option:`--bt-exclude-tracker` option
  503. because they are added after URIs in :option:`--bt-exclude-tracker` option are
  504. removed.
  505. .. option:: --bt-tracker-connect-timeout=<SEC>
  506. Set the connect timeout in seconds to establish connection to
  507. tracker. After the connection is established, this option makes no
  508. effect and :option:`--bt-tracker-timeout` option is used instead. Default:
  509. ``60``
  510. .. option:: --bt-tracker-interval=<SEC>
  511. Set the interval in seconds between tracker requests. This
  512. completely overrides interval value and aria2 just uses this value
  513. and ignores the min interval and interval value in the response of
  514. tracker. If ``0`` is set, aria2 determines interval based on the
  515. response of tracker and the download progress. Default: ``0``
  516. .. option:: --bt-tracker-timeout=<SEC>
  517. Set timeout in seconds. Default: ``60``
  518. .. option:: --dht-entry-point=<HOST>:<PORT>
  519. Set host and port as an entry point to IPv4 DHT network.
  520. .. option:: --dht-entry-point6=<HOST>:<PORT>
  521. Set host and port as an entry point to IPv6 DHT network.
  522. .. option:: --dht-file-path=<PATH>
  523. Change the IPv4 DHT routing table file to PATH.
  524. Default: ``$HOME/.aria2/dht.dat``
  525. .. option:: --dht-file-path6=<PATH>
  526. Change the IPv6 DHT routing table file to PATH.
  527. Default: ``$HOME/.aria2/dht6.dat``
  528. .. option:: --dht-listen-addr6=<ADDR>
  529. Specify address to bind socket for IPv6 DHT. It should be a global
  530. unicast IPv6 address of the host.
  531. .. option:: --dht-listen-port=<PORT>...
  532. Set UDP listening port used by DHT(IPv4, IPv6) and UDP tracker.
  533. Multiple ports can be specified by using ``,``, for example:
  534. ``6881,6885``. You can also use ``-`` to specify a range:
  535. ``6881-6999``. ``,`` and ``-`` can be used together.
  536. Default: ``6881-6999``
  537. .. note::
  538. Make sure that the specified ports are open for incoming UDP traffic.
  539. .. option:: --dht-message-timeout=<SEC>
  540. Set timeout in seconds. Default: ``10``
  541. .. option:: --enable-dht[=true|false]
  542. Enable IPv4 DHT functionality. It also enables UDP tracker
  543. support. If a private flag is set in a torrent, aria2 doesn't use
  544. DHT for that download even if ``true`` is given. Default: ``true``
  545. .. option:: --enable-dht6[=true|false]
  546. Enable IPv6 DHT functionality. If a private flag is set in a
  547. torrent, aria2 doesn't use DHT for that download even if ``true`` is
  548. given. Use :option:`--dht-listen-port` option to specify port number to
  549. listen on. See also :option:`--dht-listen-addr6` option.
  550. .. option:: --enable-peer-exchange[=true|false]
  551. Enable Peer Exchange extension. If a private flag is set in a torrent, this
  552. feature is disabled for that download even if ``true`` is given.
  553. Default: ``true``
  554. .. option:: --follow-torrent=true|false|mem
  555. If ``true`` or ``mem`` is specified, when a file whose suffix is ``.torrent`` or content
  556. type is ``application/x-bittorrent`` is downloaded, aria2 parses it as a torrent
  557. file and downloads files mentioned in it.
  558. If ``mem`` is specified, a torrent file is not written to the disk, but is just
  559. kept in memory.
  560. If ``false`` is specified, the ``.torrent`` file is downloaded to the disk, but
  561. is not parsed as a torrent and its contents are not downloaded.
  562. Default: ``true``
  563. .. option:: -O, --index-out=<INDEX>=<PATH>
  564. Set file path for file with index=INDEX. You can find the file index
  565. using the :option:`--show-files <-S>` option. PATH is a relative path to the
  566. path specified in :option:`--dir <-d>` option. You can use this option multiple
  567. times. Using this option, you can specify the output filenames of
  568. BitTorrent downloads.
  569. .. option:: --listen-port=<PORT>...
  570. Set TCP port number for BitTorrent downloads.
  571. Multiple ports can be specified by using ``,``, for example: ``6881,6885``.
  572. You can also use ``-`` to specify a range: ``6881-6999``.
  573. ``,`` and ``-`` can be used together: ``6881-6889,6999``.
  574. Default: ``6881-6999``
  575. .. note::
  576. Make sure that the specified ports are open for incoming TCP traffic.
  577. .. option:: --max-overall-upload-limit=<SPEED>
  578. Set max overall upload speed in bytes/sec.
  579. ``0`` means unrestricted.
  580. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  581. To limit the upload speed per torrent, use :option:`--max-upload-limit <-u>` option.
  582. Default: ``0``
  583. .. option:: -u, --max-upload-limit=<SPEED>
  584. Set max upload speed per each torrent in bytes/sec.
  585. ``0`` means unrestricted.
  586. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  587. To limit the overall upload speed, use :option:`--max-overall-upload-limit` option.
  588. Default: ``0``
  589. .. option:: --peer-id-prefix=<PEER_ID_PREFIX>
  590. Specify the prefix of peer ID. The peer ID in
  591. BitTorrent is 20 byte length. If more than 20
  592. bytes are specified, only first 20 bytes are
  593. used. If less than 20 bytes are specified, random
  594. byte data are added to make its length 20 bytes.
  595. Default: ``aria2/$VERSION-``, $VERSION is replaced by package version.
  596. .. option:: --seed-ratio=<RATIO>
  597. Specify share ratio. Seed completed torrents until share ratio reaches
  598. RATIO.
  599. You are strongly encouraged to specify equals or more than ``1.0`` here.
  600. Specify ``0.0`` if you intend to do seeding regardless of share ratio.
  601. If :option:`--seed-time` option is specified along with this option, seeding ends when
  602. at least one of the conditions is satisfied.
  603. Default: ``1.0``
  604. .. option:: --seed-time=<MINUTES>
  605. Specify seeding time in minutes. Also see the :option:`--seed-ratio` option.
  606. .. note::
  607. Specifying :option:`--seed-time=0 <--seed-time>` disables seeding after download completed.
  608. .. option:: -T, --torrent-file=<TORRENT_FILE>
  609. The path to the ".torrent" file. You are not required to use this
  610. option because you can specify ".torrent" files without :option:`--torrent-file <-T>`.
  611. Metalink Specific Options
  612. ~~~~~~~~~~~~~~~~~~~~~~~~~
  613. .. option:: --follow-metalink=true|false|mem
  614. If ``true`` or ``mem`` is specified, when a file whose suffix is ``.meta4`` or ``.metalink`` or content
  615. type of ``application/metalink4+xml`` or ``application/metalink+xml`` is downloaded, aria2 parses it as a metalink
  616. file and downloads files mentioned in it.
  617. If ``mem`` is specified, a metalink file is not written to the disk, but is just
  618. kept in memory.
  619. If ``false`` is specified, the ``.metalink`` file is downloaded to
  620. the disk, but is not parsed as a metalink file and its contents are not
  621. downloaded.
  622. Default: ``true``
  623. .. option:: --metalink-base-uri=<URI>
  624. Specify base URI to resolve relative URI in metalink:url and
  625. metalink:metaurl element in a metalink file stored in local disk. If
  626. URI points to a directory, URI must end with ``/``.
  627. .. option:: -M, --metalink-file=<METALINK_FILE>
  628. The file path to ".meta4" and ".metalink" file. Reads input from stdin when ``-`` is
  629. specified. You are not required to use this option because you can
  630. specify ".metalink" files without :option:`--metalink-file <-M>`.
  631. .. option:: --metalink-language=<LANGUAGE>
  632. The language of the file to download.
  633. .. option:: --metalink-location=<LOCATION>[,...]
  634. The location of the preferred server.
  635. A comma-delimited list of locations is acceptable, for example, ``jp,us``.
  636. .. option:: --metalink-os=<OS>
  637. The operating system of the file to download.
  638. .. option:: --metalink-version=<VERSION>
  639. The version of the file to download.
  640. .. option:: --metalink-preferred-protocol=<PROTO>
  641. Specify preferred protocol.
  642. The possible values are ``http``, ``https``, ``ftp`` and ``none``.
  643. Specify ``none`` to disable this feature.
  644. Default: ``none``
  645. .. option:: --metalink-enable-unique-protocol[=true|false]
  646. If ``true`` is given and several protocols are available for a mirror in a
  647. metalink file, aria2 uses one of them.
  648. Use :option:`--metalink-preferred-protocol` option to specify the preference of
  649. protocol.
  650. Default: ``true``
  651. RPC Options
  652. ~~~~~~~~~~~
  653. .. option:: --enable-rpc[=true|false]
  654. Enable JSON-RPC/XML-RPC server. It is strongly recommended to set username
  655. and password using :option:`--rpc-user` and :option:`--rpc-passwd`
  656. option. See also :option:`--rpc-listen-port` option. Default: ``false``
  657. .. option:: --pause[=true|false]
  658. Pause download after added. This option is effective only when
  659. :option:`--enable-rpc=true <--enable-rpc>` is given.
  660. Default: ``false``
  661. .. option:: --rpc-allow-origin-all[=true|false]
  662. Add Access-Control-Allow-Origin header field with value ``*`` to the
  663. RPC response.
  664. Default: ``false``
  665. .. option:: --rpc-certificate=<FILE>
  666. Use the certificate in FILE for RPC server. The certificate must be
  667. either in PKCS12 (.p12, .pfx) or in PEM format.
  668. PKCS12 files must contain the certificate, a key and optionally a chain
  669. of additional certificates. Only PKCS12 files with a blank import password
  670. can be opened!
  671. When using PEM, you have to specify the private key via :option:`--rpc-private-key`
  672. as well. Use :option:`--rpc-secure` option to enable encryption.
  673. .. note::
  674. *WinTLS* does not support PEM files at the moment. Users have to use PKCS12
  675. files.
  676. .. note::
  677. *AppleTLS* users should use the Keychain Access utility to first generate a
  678. self-signed SSL-Server certificate, e.g. using the wizard, and get the
  679. SHA-1 fingerprint from the Information dialog corresponding to that new
  680. certificate.
  681. To start aria2c with :option:`--rpc-secure` use
  682. `--rpc-certificate=<SHA-1>` and just omit the :option:`--rpc-private-key`
  683. option.
  684. .. option:: --rpc-listen-all[=true|false]
  685. Listen incoming JSON-RPC/XML-RPC requests on all network interfaces. If false
  686. is given, listen only on local loopback interface. Default: ``false``
  687. .. option:: --rpc-listen-port=<PORT>
  688. Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible
  689. Values: ``1024`` -``65535`` Default: ``6800``
  690. .. option:: --rpc-max-request-size=<SIZE>
  691. Set max size of JSON-RPC/XML-RPC request. If aria2 detects the request is
  692. more than SIZE bytes, it drops connection. Default: ``2M``
  693. .. option:: --rpc-passwd=<PASSWD>
  694. Set JSON-RPC/XML-RPC password.
  695. .. option:: --rpc-private-key=<FILE>
  696. Use the private key in FILE for RPC server. The private key must be
  697. decrypted and in PEM format. Use :option:`--rpc-secure` option to
  698. enable encryption. See also :option:`--rpc-certificate` option.
  699. .. option:: --rpc-save-upload-metadata[=true|false]
  700. Save the uploaded torrent or metalink metadata in the directory
  701. specified by :option:`--dir` option. The filename consists of SHA-1
  702. hash hex string of metadata plus extension. For torrent, the
  703. extension is '.torrent'. For metalink, it is '.meta4'. If false is
  704. given to this option, the downloads added by
  705. :func:`aria2.addTorrent` or :func:`aria2.addMetalink` will not be
  706. saved by :option:`--save-session` option. Default: ``false``
  707. .. option:: --rpc-secure[=true|false]
  708. RPC transport will be encrypted by SSL/TLS. The RPC clients must
  709. use https scheme to access the server. For WebSocket client, use wss
  710. scheme. Use :option:`--rpc-certificate` and
  711. :option:`--rpc-private-key` options to specify the server
  712. certificate and private key.
  713. .. option:: --rpc-user=<USER>
  714. Set JSON-RPC/XML-RPC user.
  715. Advanced Options
  716. ~~~~~~~~~~~~~~~~
  717. .. option:: --allow-overwrite[=true|false]
  718. Restart download from scratch if the corresponding control file
  719. doesn't exist. See also :option:`--auto-file-renaming` option. Default:
  720. ``false``
  721. .. option:: --allow-piece-length-change[=true|false]
  722. If false is given, aria2 aborts download when a piece length is different
  723. from one in a control file.
  724. If true is given, you can proceed but some download progress will be lost.
  725. Default: ``false``
  726. .. option:: --always-resume[=true|false]
  727. Always resume download. If ``true`` is given, aria2 always tries to
  728. resume download and if resume is not possible, aborts download. If
  729. ``false`` is given, when all given URIs do not support resume or aria2
  730. encounters ``N`` URIs which does not support resume (``N`` is the value
  731. specified using :option:`--max-resume-failure-tries` option), aria2
  732. downloads file from scratch. See :option:`--max-resume-failure-tries`
  733. option. Default: ``true``
  734. .. option:: --async-dns[=true|false]
  735. Enable asynchronous DNS.
  736. Default: ``true``
  737. .. option:: --async-dns-server=<IPADDRESS>[,...]
  738. Comma separated list of DNS server address used in asynchronous DNS
  739. resolver. Usually asynchronous DNS resolver reads DNS server
  740. addresses from ``/etc/resolv.conf``. When this option is used, it uses
  741. DNS servers specified in this option instead of ones in
  742. ``/etc/resolv.conf``. You can specify both IPv4 and IPv6 address. This
  743. option is useful when the system does not have ``/etc/resolv.conf`` and
  744. user does not have the permission to create it.
  745. .. option:: --auto-file-renaming[=true|false]
  746. Rename file name if the same file already exists.
  747. This option works only in HTTP(S)/FTP download.
  748. The new file name has a dot and a number(1..9999) appended.
  749. Default: ``true``
  750. .. option:: --auto-save-interval=<SEC>
  751. Save a control file(\*.aria2) every SEC seconds.
  752. If ``0`` is given, a control file is not saved during download. aria2 saves a
  753. control file when it stops regardless of the value.
  754. The possible values are between ``0`` to ``600``.
  755. Default: ``60``
  756. .. option:: --conditional-get[=true|false]
  757. Download file only when the local file is older than remote
  758. file. This function only works with HTTP(S) downloads only. It does
  759. not work if file size is specified in Metalink. It also ignores
  760. Content-Disposition header. If a control file exists, this option
  761. will be ignored. This function uses If-Modified-Since header to get
  762. only newer file conditionally. When getting modification time of
  763. local file, it uses user supplied filename(see :option:`--out <-o>` option) or
  764. filename part in URI if :option:`--out <-o>` is not specified.
  765. To overwrite existing file, :option:`--allow-overwrite` is required.
  766. Default: ``false``
  767. .. option:: --conf-path=<PATH>
  768. Change the configuration file path to PATH.
  769. Default: ``$HOME/.aria2/aria2.conf``
  770. .. option:: --console-log-level=<LEVEL>
  771. Set log level to output to console. LEVEL is either ``debug``,
  772. ``info``, ``notice``, ``warn`` or ``error``. Default: ``notice``
  773. .. option:: -D, --daemon[=true|false]
  774. Run as daemon. The current working directory will be changed to ``/``
  775. and standard input, standard output and standard error will be
  776. redirected to ``/dev/null``. Default: ``false``
  777. .. option:: --deferred-input[=true|false]
  778. If ``true`` is given, aria2 does not read all URIs and options from file
  779. specified by :option:`--input-file <-i>` option at startup,
  780. but it reads one by one when it
  781. needs later. This may reduce memory usage if input file contains a
  782. lot of URIs to download. If ``false`` is given, aria2 reads all URIs
  783. and options at startup.
  784. Default: ``false``
  785. .. option:: --disable-ipv6[=true|false]
  786. Disable IPv6. This is useful if you have to use broken DNS and want
  787. to avoid terribly slow AAAA record lookup. Default: ``false``
  788. .. option:: --disk-cache=<SIZE>
  789. Enable disk cache. If SIZE is ``0``, the disk cache is
  790. disabled. This feature caches the downloaded data in memory, which
  791. grows to at most SIZE bytes. The cache storage is created for aria2
  792. instance and shared by all downloads. The one advantage of the disk
  793. cache is reduce the disk I/O because the data are written in larger
  794. unit and it is reordered by the offset of the file. If hash
  795. checking is involved and the data are cached in memory, we don't
  796. need to read them from the disk. SIZE can include ``K`` or ``M``
  797. (1K = 1024, 1M = 1024K). Default: ``16M``
  798. .. option:: --download-result=<OPT>
  799. This option changes the way ``Download Results`` is formatted. If OPT
  800. is ``default``, print GID, status, average download speed and
  801. path/URI. If multiple files are involved, path/URI of first
  802. requested file is printed and remaining ones are omitted. If OPT is
  803. ``full``, print GID, status, average download speed, percentage of
  804. progress and path/URI. The percentage of progress and path/URI are
  805. printed for each requested file in each row.
  806. Default: ``default``
  807. .. option:: --enable-mmap[=true|false]
  808. Map files into memory. This option may not work if the file space
  809. is not pre-allocated. See :option:`--file-allocation`.
  810. Default: ``false``
  811. .. option:: --event-poll=<POLL>
  812. Specify the method for polling events. The possible values are
  813. ``epoll``, ``kqueue``, ``port``, ``poll`` and ``select``. For each ``epoll``,
  814. ``kqueue``, ``port`` and ``poll``, it is available if system supports it.
  815. ``epoll`` is available on recent Linux. ``kqueue`` is available on
  816. various \*BSD systems including Mac OS X. ``port`` is available on Open
  817. Solaris. The default value may vary depending on the system you use.
  818. .. option:: --file-allocation=<METHOD>
  819. Specify file allocation method.
  820. ``none`` doesn't pre-allocate file space. ``prealloc`` pre-allocates file space
  821. before download begins. This may take some time depending on the size of the
  822. file.
  823. If you are using newer file systems such as ext4
  824. (with extents support), btrfs, xfs or NTFS(MinGW build only), ``falloc`` is
  825. your best choice. It allocates large(few GiB)
  826. files almost instantly. Don't use ``falloc`` with
  827. legacy file systems such as ext3 and FAT32 because it takes
  828. almost same time as ``prealloc`` and it blocks aria2
  829. entirely until allocation finishes. ``falloc`` may
  830. not be available if your system doesn't have
  831. :manpage:`posix_fallocate(3)` function.
  832. ``trunc`` uses :manpage:`ftruncate(2)` system call or
  833. platform-specific counterpart to truncate a file to a specified
  834. length.
  835. Possible Values: ``none``, ``prealloc``, ``trunc``, ``falloc``
  836. Default: ``prealloc``
  837. .. option:: --force-save[=true|false]
  838. Save download with :option:`--save-session <--save-session>` option
  839. even if the download is completed or removed. This option also saves
  840. control file in that situations. This may be useful to save
  841. BitTorrent seeding which is recognized as completed state.
  842. Default: ``false``
  843. .. option:: --gid=<GID>
  844. Set GID manually. aria2 identifies each download by the ID called
  845. GID. The GID must be hex string of 16 characters, thus [0-9a-zA-Z]
  846. are allowed and leading zeros must not be stripped. The GID all 0 is
  847. reserved and must not be used. The GID must be unique, otherwise
  848. error is reported and the download is not added. This option is
  849. useful when restoring the sessions saved using
  850. :option:`--save-session <--save-session>` option. If this option is
  851. not used, new GID is generated by aria2.
  852. .. option:: --hash-check-only[=true|false]
  853. If ``true`` is given, after hash check using
  854. :option:`--check-integrity <-V>` option,
  855. abort download whether or not download is complete.
  856. Default: ``false``
  857. .. option:: --human-readable[=true|false]
  858. Print sizes and speed in human readable format (e.g., 1.2Ki, 3.4Mi)
  859. in the console readout. Default: ``true``
  860. .. option:: --interface=<INTERFACE>
  861. Bind sockets to given interface. You can specify interface name, IP
  862. address and hostname.
  863. Possible Values: interface, IP address, hostname
  864. .. note::
  865. If an interface has multiple addresses, it is highly recommended to
  866. specify IP address explicitly. See also :option:`--disable-ipv6`. If your
  867. system doesn't have :manpage:`getifaddrs(3)`, this option doesn't accept interface
  868. name.
  869. .. option:: --max-download-result=<NUM>
  870. Set maximum number of download result kept in memory. The download
  871. results are completed/error/removed downloads. The download results
  872. are stored in FIFO queue and it can store at most NUM download
  873. results. When queue is full and new download result is created,
  874. oldest download result is removed from the front of the queue and
  875. new one is pushed to the back. Setting big number in this option may
  876. result high memory consumption after thousands of
  877. downloads. Specifying 0 means no download result is kept. Default:
  878. ``1000``
  879. .. option:: --max-resume-failure-tries=<N>
  880. When used with :option:`--always-resume=false, <--always-resume>` aria2 downloads file from
  881. scratch when aria2 detects N number of URIs that does not support
  882. resume. If N is ``0``, aria2 downloads file from scratch when all
  883. given URIs do not support resume. See :option:`--always-resume` option.
  884. Default: ``0``
  885. .. option:: --log-level=<LEVEL>
  886. Set log level to output.
  887. LEVEL is either ``debug``, ``info``, ``notice``, ``warn`` or ``error``.
  888. Default: ``debug``
  889. .. option:: --on-bt-download-complete=<COMMAND>
  890. For BitTorrent, a command specified in :option:`--on-download-complete` is
  891. called after download completed and seeding is over. On the other
  892. hand, this option set the command to be executed after download
  893. completed but before seeding.
  894. See `Event Hook`_ for more details about COMMAND.
  895. Possible Values: ``/path/to/command``
  896. .. option:: --on-download-complete=<COMMAND>
  897. Set the command to be executed after download completed. See
  898. See `Event Hook`_ for more details about COMMAND.
  899. See also :option:`--on-download-stop` option.
  900. Possible Values: ``/path/to/command``
  901. .. option:: --on-download-error=<COMMAND>
  902. Set the command to be executed after download aborted due to error.
  903. See `Event Hook`_ for more details about COMMAND.
  904. See also :option:`--on-download-stop` option. Possible Values:
  905. ``/path/to/command``
  906. .. option:: --on-download-pause=<COMMAND>
  907. Set the command to be executed after download was paused.
  908. See `Event Hook`_ for more details about COMMAND.
  909. Possible Values: ``/path/to/command``
  910. .. option:: --on-download-start=<COMMAND>
  911. Set the command to be executed after download got started.
  912. See `Event Hook`_ for more details about COMMAND.
  913. Possible Values: ``/path/to/command``
  914. .. option:: --on-download-stop=<COMMAND>
  915. Set the command to be executed after download stopped. You can override
  916. the command to be executed for particular download result using
  917. :option:`--on-download-complete` and :option:`--on-download-error`. If they are
  918. specified, command specified in this option is not executed.
  919. See `Event Hook`_ for more details about COMMAND.
  920. Possible Values: ``/path/to/command``
  921. .. option:: --piece-length=<LENGTH>
  922. Set a piece length for HTTP/FTP downloads. This is the boundary when
  923. aria2 splits a file. All splits occur at multiple of this
  924. length. This option will be ignored in BitTorrent downloads. It
  925. will be also ignored if Metalink file contains piece hashes.
  926. Default: ``1M``
  927. .. note::
  928. The possible usecase of :option:`--piece-length`
  929. option is change the request range in one HTTP pipelined request.
  930. To enable HTTP pipelining use
  931. :option:`--enable-http-pipelining`.
  932. .. option:: --show-console-readout[=true|false]
  933. Show console readout. Default: ``true``
  934. .. option:: --summary-interval=<SEC>
  935. Set interval in seconds to output download progress summary.
  936. Setting ``0`` suppresses the output.
  937. Default: ``60``
  938. .. note::
  939. In multi file torrent downloads, the files adjacent forward to the specified files
  940. are also allocated if they share the same piece.
  941. .. option:: -Z, --force-sequential[=true|false]
  942. Fetch URIs in the command-line sequentially and download each URI in a
  943. separate session, like the usual command-line download utilities.
  944. Default: ``false``
  945. .. option:: --max-overall-download-limit=<SPEED>
  946. Set max overall download speed in bytes/sec. ``0`` means
  947. unrestricted. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K). To
  948. limit the download speed per download, use :option:`--max-download-limit`
  949. option. Default: ``0``
  950. .. option:: --max-download-limit=<SPEED>
  951. Set max download speed per each download in bytes/sec. ``0`` means
  952. unrestricted. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K). To
  953. limit the overall download speed, use :option:`--max-overall-download-limit`
  954. option. Default: ``0``
  955. .. option:: --no-conf[=true|false]
  956. Disable loading aria2.conf file.
  957. .. option:: --no-file-allocation-limit=<SIZE>
  958. No file allocation is made for files whose size is smaller than SIZE.
  959. You can append ``K`` or ``M`` (1K = 1024, 1M = 1024K).
  960. Default: ``5M``
  961. .. option:: -P, --parameterized-uri[=true|false]
  962. Enable parameterized URI support.
  963. You can specify set of parts: ``http://{sv1,sv2,sv3}/foo.iso``.
  964. Also you can specify numeric sequences with step counter:
  965. ``http://host/image[000-100:2].img``.
  966. A step counter can be omitted.
  967. If all URIs do not point to the same file, such as the second example above,
  968. -Z option is required.
  969. Default: ``false``
  970. .. option:: -q, --quiet[=true|false]
  971. Make aria2 quiet (no console output).
  972. Default: ``false``
  973. .. option:: --realtime-chunk-checksum[=true|false]
  974. Validate chunk of data by calculating checksum while downloading a file if
  975. chunk checksums are provided.
  976. Default: ``true``
  977. .. option:: --remove-control-file[=true|false]
  978. Remove control file before download. Using with
  979. :option:`--allow-overwrite=true, <--allow-overwrite>` download always starts from
  980. scratch. This will be useful for users behind proxy server which
  981. disables resume.
  982. .. option:: --save-session=<FILE>
  983. Save error/unfinished downloads to FILE on exit. You can pass this
  984. output file to aria2c with :option:`--input-file <-i>` option on
  985. restart. If you like the output to be gzipped append a .gz extension to
  986. the file name.
  987. Please note that downloads added by
  988. :func:`aria2.addTorrent` and :func:`aria2.addMetalink` RPC method
  989. and whose metadata could not be saved as a file are not saved.
  990. Downloads removed using :func:`aria2.remove` and
  991. :func:`aria2.forceRemove` will not be saved. GID is also saved with
  992. :option:`gid <--gid>`, but there are some restrictions, see below.
  993. .. note::
  994. Normally, GID of the download itself is saved. But some downloads
  995. use metadata (e.g., BitTorrent and Metalink). In this case, there
  996. are some restrictions.
  997. 1. magnet URI, and followed by torrent download
  998. GID of BitTorrent metadata download is saved.
  999. 2. URI to torrent file, and followed by torrent download
  1000. GID of torrent file download is saved.
  1001. 3. URI to metalink file, and followed by file downloads described in metalink file
  1002. GID of metalink file download is saved.
  1003. 4. local torrent file
  1004. GID of torrent download is saved.
  1005. 5. local metalink file
  1006. Any meaningful GID is not saved.
  1007. .. option:: --save-session-interval=<SEC>
  1008. Save error/unfinished downloads to a file specified by
  1009. :option:`--save-session` option every SEC seconds. If ``0`` is
  1010. given, file will be saved only when aria2 exits. Default: ``0``
  1011. .. option:: --stop=<SEC>
  1012. Stop application after SEC seconds has passed.
  1013. If ``0`` is given, this feature is disabled.
  1014. Default: ``0``
  1015. .. option:: --stop-with-process=<PID>
  1016. Stop application when process PID is not running. This is useful if
  1017. aria2 process is forked from a parent process. The parent process
  1018. can fork aria2 with its own pid and when parent process exits for
  1019. some reason, aria2 can detect it and shutdown itself.
  1020. .. option:: --truncate-console-readout[=true|false]
  1021. Truncate console readout to fit in a single line.
  1022. Default: ``true``
  1023. .. option:: -v, --version
  1024. Print the version number, copyright and the configuration information and
  1025. exit.
  1026. Notes for Options
  1027. ~~~~~~~~~~~~~~~~~
  1028. Optional arguments
  1029. ^^^^^^^^^^^^^^^^^^
  1030. The options that have its argument surrounded by square brackets([])
  1031. take an optional argument. Usually omiting the argument is evaluated to ``true``.
  1032. If you use short form of these options(such as ``-V``) and give
  1033. an argument, then the option name and its argument should be concatenated(e.g.
  1034. ``-Vfalse``). If any spaces are inserted between the option name and the argument,
  1035. the argument will be treated as URI and usually this is not what you expect.
  1036. Units (K and M)
  1037. ^^^^^^^^^^^^^^^
  1038. Some options takes ``K`` and ``M`` to conveniently represent 1024 and
  1039. 1048576 respectively. aria2 detects these characters in
  1040. case-insensitive way. In other words, ``k`` and ``m`` can be used as
  1041. well as ``K`` and ``M`` respectively.
  1042. URI, MAGNET, TORRENT_FILE, METALINK_FILE
  1043. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1044. You can specify multiple URIs in command-line. Unless you specify
  1045. :option:`--force-sequential <-Z>` option, all URIs must point to the same file or downloading will
  1046. fail.
  1047. You can specify arbitrary number of BitTorrent Magnet URI. Please note
  1048. that they are always treated as a separate download. Both hex encoded
  1049. 40 characters Info Hash and Base32 encoded 32 characters Info Hash are
  1050. supported. The multiple ``tr`` parameters are supported. Because
  1051. BitTorrent Magnet URI is likely to contain ``&`` character, it is highly
  1052. recommended to always quote URI with single(``'``) or double(``"``) quotation.
  1053. It is strongly recommended to enable DHT especially when ``tr``
  1054. parameter is missing. See http://www.bittorrent.org/beps/bep_0009.html
  1055. for more details about BitTorrent Magnet URI.
  1056. You can also specify arbitrary number of torrent files and Metalink
  1057. documents stored on a local drive. Please note that they are always
  1058. treated as a separate download. Both Metalink4 and Metalink version
  1059. 3.0 are supported.
  1060. You can specify both torrent file with -T option and URIs. By doing
  1061. this, you can download a file from both torrent swarm and HTTP(S)/FTP
  1062. server at the same time, while the data from HTTP(S)/FTP are uploaded
  1063. to the torrent swarm. For single file torrents, URI can be a complete
  1064. URI pointing to the resource or if URI ends with /, name in torrent
  1065. file in torrent is added. For multi-file torrents, name and path are
  1066. added to form a URI for each file.
  1067. .. note::
  1068. Make sure that URI is quoted with single(``'``) or double(``"``) quotation if it
  1069. contains ``&`` or any characters that have special meaning in shell.
  1070. Resuming Download
  1071. ~~~~~~~~~~~~~~~~~
  1072. Usually, you can resume transfer by just issuing same command(aria2c
  1073. URI) if the previous transfer is made by aria2.
  1074. If the previous transfer is made by a browser or wget like sequential
  1075. download manager, then use :option:`--continue <-c>` option to continue the transfer.
  1076. Event Hook
  1077. ~~~~~~~~~~
  1078. aria2 provides options to specify arbitrary command after specific event
  1079. occurred. Currently following options are available:
  1080. :option:`--on-bt-download-complete`,
  1081. :option:`--on-download-pause`,
  1082. :option:`--on-download-complete`.
  1083. :option:`--on-download-start`,
  1084. :option:`--on-download-error`,
  1085. :option:`--on-download-stop`.
  1086. aria2 passes 3 arguments to specified command when it is executed.
  1087. These arguments are: GID, the number of files and file path. For
  1088. HTTP, FTP downloads, usually the number of files is 1. BitTorrent
  1089. download can contain multiple files.
  1090. If number of files is more than one, file path is first one. In
  1091. other words, this is the value of path key of first struct whose
  1092. selected key is true in the response of
  1093. :func:`aria2.getFiles`
  1094. RPC method.
  1095. If you want to get all file paths, consider to use JSON-RPC/XML-RPC. Please
  1096. note that file path may change during download in HTTP because of
  1097. redirection or Content-Disposition header.
  1098. Let's see an example of how arguments are passed to command:
  1099. .. code-block:: console
  1100. $ cat hook.sh
  1101. #!/bin/sh
  1102. echo "Called with [$1] [$2] [$3]"
  1103. $ aria2c --on-download-complete hook.sh http://example.org/file.iso
  1104. Called with [1] [1] [/path/to/file.iso]
  1105. .. _exit-status:
  1106. EXIT STATUS
  1107. -----------
  1108. Because aria2 can handle multiple downloads at once, it encounters
  1109. lots of errors in a session. aria2 returns the following exit status
  1110. based on the last error encountered.
  1111. 0
  1112. If all downloads were successful.
  1113. 1
  1114. If an unknown error occurred.
  1115. 2
  1116. If time out occurred.
  1117. 3
  1118. If a resource was not found.
  1119. 4
  1120. If aria2 saw the specfied number of "resource not found" error.
  1121. See :option:`--max-file-not-found` option).
  1122. 5
  1123. If a download aborted because download speed was too slow.
  1124. See :option:`--lowest-speed-limit` option)
  1125. 6
  1126. If network problem occurred.
  1127. 7
  1128. If there were unfinished downloads. This error is only reported if
  1129. all finished downloads were successful and there were unfinished
  1130. downloads in a queue when aria2 exited by pressing :kbd:`Ctrl-C` by an user
  1131. or sending TERM or INT signal.
  1132. 8
  1133. If remote server did not support resume when resume was required to
  1134. complete download.
  1135. 9
  1136. If there was not enough disk space available.
  1137. 10
  1138. If piece length was different from one in .aria2 control file. See
  1139. :option:`--allow-piece-length-change` option.
  1140. 11
  1141. If aria2 was downloading same file at that moment.
  1142. 12
  1143. If aria2 was downloading same info hash torrent at that moment.
  1144. 13
  1145. If file already existed. See :option:`--allow-overwrite` option.
  1146. 14
  1147. If renaming file failed. See :option:`--auto-file-renaming` option.
  1148. 15
  1149. If aria2 could not open existing file.
  1150. 16
  1151. If aria2 could not create new file or truncate existing file.
  1152. 17
  1153. If file I/O error occurred.
  1154. 18
  1155. If aria2 could not create directory.
  1156. 19
  1157. If name resolution failed.
  1158. 20
  1159. If aria2 could not parse Metalink document.
  1160. 21
  1161. If FTP command failed.
  1162. 22
  1163. If HTTP response header was bad or unexpected.
  1164. 23
  1165. If too many redirections occurred.
  1166. 24
  1167. If HTTP authorization failed.
  1168. 25
  1169. If aria2 could not parse bencoded file(usually ".torrent" file).
  1170. 26
  1171. If ".torrent" file was corrupted or missing information that aria2 needed.
  1172. 27
  1173. If Magnet URI was bad.
  1174. 28
  1175. If bad/unrecognized option was given or unexpected option argument
  1176. was given.
  1177. 29
  1178. If the remote server was unable to handle the request due to a
  1179. temporary overloading or maintenance.
  1180. 30
  1181. If aria2 could not parse JSON-RPC request.
  1182. .. note::
  1183. An error occurred in a finished download will not be reported
  1184. as exit status.
  1185. ENVIRONMENT
  1186. -----------
  1187. aria2 recognizes the following environment variables.
  1188. ``http_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1189. Specify proxy server for use in HTTP.
  1190. Overrides http-proxy value in configuration file.
  1191. The command-line option :option:`--http-proxy` overrides this value.
  1192. ``https_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1193. Specify proxy server for use in HTTPS.
  1194. Overrides https-proxy value in configuration file.
  1195. The command-line option :option:`--https-proxy` overrides this value.
  1196. ``ftp_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1197. Specify proxy server for use in FTP.
  1198. Overrides ftp-proxy value in configuration file.
  1199. The command-line option :option:`--ftp-proxy` overrides this value.
  1200. ``all_proxy [http://][USER:PASSWORD@]HOST[:PORT]``
  1201. Specify proxy server for use if no protocol-specific proxy is specified.
  1202. Overrides all-proxy value in configuration file.
  1203. The command-line option :option:`--all-proxy` overrides this value.
  1204. .. note::
  1205. Although aria2 accepts ``ftp://`` and ``https://`` scheme in proxy URI, it
  1206. simply assumes that ``http://`` is specified and does not change its
  1207. behavior based on the specified scheme.
  1208. ``no_proxy [DOMAIN,...]``
  1209. Specify comma-separated hostname, domains and network address with
  1210. or without CIDR block to which proxy should not be used. Overrides
  1211. no-proxy value in configuration file. The command-line option
  1212. :option:`--no-proxy` overrides this value.
  1213. FILES
  1214. -----
  1215. aria2.conf
  1216. ~~~~~~~~~~
  1217. By default, aria2 parses ``$HOME/.aria2/aria2.conf`` as a
  1218. configuraiton file. You can specify the path to configuration file
  1219. using :option:`--conf-path` option. If you don't want to use the
  1220. configuraiton file, use :option:`--no-conf` option.
  1221. The configuration file is a text file and has 1 option per each
  1222. line. In each line, you can specify name-value pair in the format:
  1223. ``NAME=VALUE``, where name is the long command-line option name without
  1224. ``--`` prefix. You can use same syntax for the command-line option. The
  1225. lines beginning ``#`` are treated as comments::
  1226. # sample configuration file for aria2c
  1227. listen-port=60000
  1228. dht-listen-port=60000
  1229. seed-ratio=1.0
  1230. max-upload-limit=50K
  1231. ftp-pasv=true
  1232. .. note::
  1233. The confidential information such as user/password might be included
  1234. in the configuration file. It is recommended to change file mode
  1235. bits of the configuration file (e.g., ``chmod 600 aria2.conf``), so
  1236. that other user cannot see the contents of the file.
  1237. dht.dat
  1238. ~~~~~~~~
  1239. By default, the routing table of IPv4 DHT is saved to the path
  1240. ``$HOME/.aria2/dht.dat`` and the routing table of IPv6 DHT is saved to
  1241. the path ``$HOME/.aria2/dht6.dat``.
  1242. Netrc
  1243. ~~~~~
  1244. Netrc support is enabled by default for HTTP(S)/FTP. To disable netrc
  1245. support, specify :option:`--no-netrc <-n>` option. Your .netrc file should have correct
  1246. permissions(600).
  1247. If machine name starts ``.``, aria2 performs domain-match instead of
  1248. exact match. This is an extension of aria2. For example of domain
  1249. match, imagine the following .netrc entry::
  1250. machine .example.org login myid password mypasswd
  1251. ``aria2.example.org`` domain-matches ``.example.org`` and uses ``myid`` and
  1252. ``mypasswd``.
  1253. Some domain-match example follow: ``example.net`` does not domain-match
  1254. ``.example.org``. ``example.org`` does not domain-match ``.example.org``
  1255. because of preceding ``.``. If you want to match ``example.org``, specify
  1256. ``example.org``.
  1257. Control File
  1258. ~~~~~~~~~~~~
  1259. aria2 uses a control file to track the progress of a download. A
  1260. control file is placed in the same directory as the downloading file
  1261. and its filename is the filename of downloading file with ``.aria2``
  1262. appended. For example, if you are downloading file.zip, then the
  1263. control file should be file.zip.aria2. (There is a exception for this
  1264. naming convention. If you are downloading a multi torrent, its
  1265. control file is the "top directory" name of the torrent with ``.aria2``
  1266. appended. The "top directory" name is a value of "name" key in "info"
  1267. directory in a torrent file.)
  1268. Usually a control file is deleted once download completed. If aria2
  1269. decides that download cannot be resumed(for example, when downloading
  1270. a file from a HTTP server which doesn't support resume), a control
  1271. file is not created.
  1272. Normally if you lose a control file, you cannot resume download. But
  1273. if you have a torrent or metalink with chunk checksums for the file,
  1274. you can resume the download without a control file by giving -V option
  1275. to aria2c in command-line.
  1276. .. _input-file:
  1277. Input File
  1278. ~~~~~~~~~~
  1279. The input file can contain a list of URIs for aria2 to download. You
  1280. can specify multiple URIs for a single entity: separate URIs on a
  1281. single line using the TAB character.
  1282. Each line is treated as if it is provided in command-line argument.
  1283. Therefore they are affected by :option:`--force-sequential <-Z>` and :option:`--parameterized-uri <-P>` options.
  1284. Since URIs in the input file are directly read by aria2, they must not
  1285. be quoted with single(``'``) or double(``"``) quotation.
  1286. Lines starting with ``#`` are treated as comments and skipped.
  1287. Additionally, the following options can be specified after each line
  1288. of URIs. These optional lines must start with white space(s).
  1289. .. hlist::
  1290. :columns: 3
  1291. * :option:`all-proxy <--all-proxy>`
  1292. * :option:`all-proxy-passwd <--all-proxy-passwd>`
  1293. * :option:`all-proxy-user <--all-proxy-user>`
  1294. * :option:`allow-overwrite <--allow-overwrite>`
  1295. * :option:`allow-piece-length-change <--allow-piece-length-change>`
  1296. * :option:`always-resume <--always-resume>`
  1297. * :option:`async-dns <--async-dns>`
  1298. * :option:`auto-file-renaming <--auto-file-renaming>`
  1299. * :option:`bt-enable-lpd <--bt-enable-lpd>`
  1300. * :option:`bt-exclude-tracker <--bt-exclude-tracker>`
  1301. * :option:`bt-external-ip <--bt-external-ip>`
  1302. * :option:`bt-hash-check-seed <--bt-hash-check-seed>`
  1303. * :option:`bt-max-open-files <--bt-max-open-files>`
  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:`download-result <--download-result>`
  2215. * :option:`log <-l>`
  2216. * :option:`log-level <--log-level>`
  2217. * :option:`max-concurrent-downloads <-j>`
  2218. * :option:`max-download-result <--max-download-result>`
  2219. * :option:`max-overall-download-limit <--max-overall-download-limit>`
  2220. * :option:`max-overall-upload-limit <--max-overall-upload-limit>`
  2221. * :option:`save-cookies <--save-cookies>`
  2222. * :option:`save-session <--save-session>`
  2223. * :option:`server-stat-of <--server-stat-of>`
  2224. In addition to them, options listed in `Input File`_ subsection
  2225. are available, except for following options:
  2226. :option:`checksum <--checksum>`,
  2227. :option:`index-out <-O>`,
  2228. :option:`out <-o>`,
  2229. :option:`pause <--pause>` and
  2230. :option:`select-file <--select-file>`.
  2231. Using :option:`log <-l>` option, you can dynamically start logging or
  2232. change log file. To stop logging, give empty string("") as a parameter
  2233. value. Note that log file is always opened in append mode. This method
  2234. returns ``OK`` for success.
  2235. .. function:: aria2.getGlobalStat()
  2236. This method returns global statistics such as overall download and
  2237. upload speed. The response is of type struct and contains following
  2238. keys. The value type is string.
  2239. ``downloadSpeed``
  2240. Overall download speed (byte/sec).
  2241. ``uploadSpeed``
  2242. Overall upload speed(byte/sec).
  2243. ``numActive``
  2244. The number of active downloads.
  2245. ``numWaiting``
  2246. The number of waiting downloads.
  2247. ``numStopped``
  2248. The number of stopped downloads.
  2249. **JSON-RPC Example**
  2250. ::
  2251. >>> import urllib2, json
  2252. >>> from pprint import pprint
  2253. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2254. ... 'method':'aria2.getGlobalStat'})
  2255. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2256. >>> pprint(json.loads(c.read()))
  2257. {u'id': u'qwer',
  2258. u'jsonrpc': u'2.0',
  2259. u'result': {u'downloadSpeed': u'21846',
  2260. u'numActive': u'2',
  2261. u'numStopped': u'0',
  2262. u'numWaiting': u'0',
  2263. u'uploadSpeed': u'0'}}
  2264. **XML-RPC Example**
  2265. ::
  2266. >>> import xmlrpclib
  2267. >>> from pprint import pprint
  2268. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2269. >>> r = s.aria2.getGlobalStat()
  2270. >>> pprint(r)
  2271. {'downloadSpeed': '23136',
  2272. 'numActive': '2',
  2273. 'numStopped': '0',
  2274. 'numWaiting': '0',
  2275. 'uploadSpeed': '0'}
  2276. .. function:: aria2.purgeDownloadResult()
  2277. This method purges completed/error/removed downloads to free memory.
  2278. This method returns ``OK``.
  2279. .. function:: aria2.removeDownloadResult(gid)
  2280. This method removes completed/error/removed download denoted by *gid*
  2281. from memory. This method returns ``OK`` for success.
  2282. The following examples remove the download result of the download
  2283. GID#2089b05ecca3d829.
  2284. **JSON-RPC Example**
  2285. ::
  2286. >>> import urllib2, json
  2287. >>> from pprint import pprint
  2288. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2289. ... 'method':'aria2.removeDownloadResult',
  2290. ... 'params':['2089b05ecca3d829']})
  2291. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2292. >>> pprint(json.loads(c.read()))
  2293. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'OK'}
  2294. **XML-RPC Example**
  2295. ::
  2296. >>> import xmlrpclib
  2297. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2298. >>> s.aria2.removeDownloadResult('2089b05ecca3d829')
  2299. 'OK'
  2300. .. function:: aria2.getVersion()
  2301. This method returns version of the program and the list of enabled
  2302. features. The response is of type struct and contains following keys.
  2303. ``version``
  2304. Version number of the program in string.
  2305. ``enabledFeatures``
  2306. List of enabled features. Each feature name is of type string.
  2307. **JSON-RPC Example**
  2308. ::
  2309. >>> import urllib2, json
  2310. >>> from pprint import pprint
  2311. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2312. ... 'method':'aria2.getVersion'})
  2313. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2314. >>> pprint(json.loads(c.read()))
  2315. {u'id': u'qwer',
  2316. u'jsonrpc': u'2.0',
  2317. u'result': {u'enabledFeatures': [u'Async DNS',
  2318. u'BitTorrent',
  2319. u'Firefox3 Cookie',
  2320. u'GZip',
  2321. u'HTTPS',
  2322. u'Message Digest',
  2323. u'Metalink',
  2324. u'XML-RPC'],
  2325. u'version': u'1.11.0'}}
  2326. **XML-RPC Example**
  2327. ::
  2328. >>> import xmlrpclib
  2329. >>> from pprint import pprint
  2330. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2331. >>> r = s.aria2.getVersion()
  2332. >>> pprint(r)
  2333. {'enabledFeatures': ['Async DNS',
  2334. 'BitTorrent',
  2335. 'Firefox3 Cookie',
  2336. 'GZip',
  2337. 'HTTPS',
  2338. 'Message Digest',
  2339. 'Metalink',
  2340. 'XML-RPC'],
  2341. 'version': '1.11.0'}
  2342. .. function:: aria2.getSessionInfo()
  2343. This method returns session information.
  2344. The response is of type struct and contains following key.
  2345. ``sessionId``
  2346. Session ID, which is generated each time when aria2 is invoked.
  2347. **JSON-RPC Example**
  2348. ::
  2349. >>> import urllib2, json
  2350. >>> from pprint import pprint
  2351. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2352. ... 'method':'aria2.getSessionInfo'})
  2353. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2354. >>> pprint(json.loads(c.read()))
  2355. {u'id': u'qwer',
  2356. u'jsonrpc': u'2.0',
  2357. u'result': {u'sessionId': u'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}}
  2358. **XML-RPC Example**
  2359. ::
  2360. >>> import xmlrpclib
  2361. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2362. >>> s.aria2.getSessionInfo()
  2363. {'sessionId': 'cd6a3bc6a1de28eb5bfa181e5f6b916d44af31a9'}
  2364. .. function:: aria2.shutdown()
  2365. This method shutdowns aria2. This method returns ``OK``.
  2366. .. function:: aria2.forceShutdown()
  2367. This method shutdowns :func:`aria2. This method behaves like aria2.shutdown`
  2368. except that any actions which takes time such as contacting BitTorrent
  2369. tracker are skipped. This method returns ``OK``.
  2370. .. function:: system.multicall(methods)
  2371. This methods encapsulates multiple method calls in a single request.
  2372. *methods* is of type array and its element is struct. The struct
  2373. contains two keys: ``methodName`` and ``params``. ``methodName`` is the
  2374. method name to call and ``params`` is array containing parameters to the
  2375. method. This method returns array of responses. The element of array
  2376. will either be a one-item array containing the return value of each
  2377. method call or struct of fault element if an encapsulated method call
  2378. fails.
  2379. In the following examples, we add 2 downloads. First one is
  2380. ``http://example.org/file`` and second one is ``file.torrent``.
  2381. **JSON-RPC Example**
  2382. ::
  2383. >>> import urllib2, json, base64
  2384. >>> from pprint import pprint
  2385. >>> jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
  2386. ... 'method':'system.multicall',
  2387. ... 'params':[[{'methodName':'aria2.addUri',
  2388. ... 'params':[['http://example.org']]},
  2389. ... {'methodName':'aria2.addTorrent',
  2390. ... 'params':[base64.b64encode(open('file.torrent').read())]}]]})
  2391. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2392. >>> pprint(json.loads(c.read()))
  2393. {u'id': u'qwer', u'jsonrpc': u'2.0', u'result': [[u'2089b05ecca3d829'], [u'd2703803b52216d1']]}
  2394. JSON-RPC also supports Batch request described in JSON-RPC 2.0 Specification::
  2395. >>> jsonreq = json.dumps([{'jsonrpc':'2.0', 'id':'qwer',
  2396. ... 'method':'aria2.addUri',
  2397. ... 'params':[['http://example.org']]},
  2398. ... {'jsonrpc':'2.0', 'id':'asdf',
  2399. ... 'method':'aria2.addTorrent',
  2400. ... 'params':[base64.b64encode(open('file.torrent').read())]}])
  2401. >>> c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
  2402. >>> pprint(json.loads(c.read()))
  2403. [{u'id': u'qwer', u'jsonrpc': u'2.0', u'result': u'2089b05ecca3d829'},
  2404. {u'id': u'asdf', u'jsonrpc': u'2.0', u'result': u'd2703803b52216d1'}]
  2405. **XML-RPC Example**
  2406. ::
  2407. >>> import xmlrpclib
  2408. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2409. >>> mc = xmlrpclib.MultiCall(s)
  2410. >>> mc.aria2.addUri(['http://example.org/file'])
  2411. >>> mc.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
  2412. >>> r = mc()
  2413. >>> tuple(r)
  2414. ('2089b05ecca3d829', 'd2703803b52216d1')
  2415. Error Handling
  2416. ~~~~~~~~~~~~~~
  2417. In JSON-RPC, aria2 returns JSON object which contains error code in
  2418. code and the error message in message.
  2419. In XML-RPC, aria2 returns faultCode=1 and the error message in
  2420. faultString.
  2421. .. _rpc_options:
  2422. Options
  2423. ~~~~~~~
  2424. Same options for :option:`--input-file <-i>` list are available. See `Input File`_ subsection for complete list of options.
  2425. In the option struct, name element is option name(without preceding
  2426. ``--``) and value element is argument as string.
  2427. JSON-RPC Example
  2428. ^^^^^^^^^^^^^^^^
  2429. ::
  2430. {'split':'1', 'http-proxy':'http://proxy/'}
  2431. XML-RPC Example
  2432. ^^^^^^^^^^^^^^^
  2433. .. code-block:: xml
  2434. <struct>
  2435. <member>
  2436. <name>split</name>
  2437. <value><string>1</string></value>
  2438. </member>
  2439. <member>
  2440. <name>http-proxy</name>
  2441. <value><string>http://proxy/</string></value>
  2442. </member>
  2443. </struct>
  2444. :option:`header <--header>` and :option:`index-out <-O>`
  2445. option are allowed multiple times in
  2446. command-line. Since name should be unique in struct(many XML-RPC
  2447. library implementation uses hash or dict for struct), single string is
  2448. not enough. To overcome this situation, they can take array as value
  2449. as well as string.
  2450. JSON-RPC Example
  2451. ^^^^^^^^^^^^^^^^
  2452. ::
  2453. {'header':['Accept-Language: ja', 'Accept-Charset: utf-8']}
  2454. XML-RPC Example
  2455. ^^^^^^^^^^^^^^^
  2456. .. code-block:: xml
  2457. <struct>
  2458. <member>
  2459. <name>header</name>
  2460. <value>
  2461. <array>
  2462. <data>
  2463. <value><string>Accept-Language: ja</string></value>
  2464. <value><string>Accept-Charset: utf-8</string></value>
  2465. </data>
  2466. </array>
  2467. </value>
  2468. </member>
  2469. </struct>
  2470. Following example adds a download with 2 options: dir and header.
  2471. header option has 2 values, so it uses a list::
  2472. >>> import xmlrpclib
  2473. >>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
  2474. >>> opts = dict(dir='/tmp',
  2475. ... header=['Accept-Language: ja',
  2476. ... 'Accept-Charset: utf-8'])
  2477. >>> s.aria2.addUri(['http://example.org/file'], opts)
  2478. '1'
  2479. JSON-RPC using HTTP GET
  2480. ~~~~~~~~~~~~~~~~~~~~~~~
  2481. The JSON-RPC interface also supports request via HTTP GET.
  2482. The encoding scheme in GET parameters is based on JSON-RPC over HTTP Specification [2008-1-15(RC1)].
  2483. The encoding of GET parameters are follows::
  2484. /jsonrpc?method=METHOD_NAME&id=ID&params=BASE64_ENCODED_PARAMS
  2485. The ``method`` and ``id`` are always treated as JSON string and their
  2486. encoding must be UTF-8.
  2487. For example, The encoded string of
  2488. ``aria2.tellStatus('2089b05ecca3d829')`` with ``id='foo'`` looks like
  2489. this::
  2490. /jsonrpc?method=aria2.tellStatus&id=foo&params=WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D
  2491. The ``params`` parameter is Base64-encoded JSON array which usually
  2492. appears in ``params`` attribute in JSON-RPC request object. In the
  2493. above example, the params is ``["2089b05ecca3d829"]``, therefore::
  2494. ["2089b05ecca3d829"] --(Base64)--> WyIyMDg5YjA1ZWNjYTNkODI5Il0=
  2495. --(Percent Encode)--> WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D
  2496. The JSON-RPC interface supports JSONP. You can specify the callback
  2497. function in ``jsoncallback`` parameter::
  2498. /jsonrpc?method=aria2.tellStatus&id=foo&params=WyIyMDg5YjA1ZWNjYTNkODI5Il0%3D&jsoncallback=cb
  2499. For Batch request, ``method`` and ``id`` parameter must not be specified.
  2500. Whole request must be specified in ``params`` parameter. For example,
  2501. Batch request::
  2502. [{'jsonrpc':'2.0', 'id':'qwer', 'method':'aria2.getVersion'},
  2503. {'jsonrpc':'2.0', 'id':'asdf', 'method':'aria2.tellActive'}]
  2504. will be encoded like this::
  2505. /jsonrpc?params=W3sianNvbnJwYyI6ICIyLjAiLCAiaWQiOiAicXdlciIsICJtZXRob2QiOiAiYXJpYTIuZ2V0VmVyc2lvbiJ9LCB7Impzb25ycGMiOiAiMi4wIiwgImlkIjogImFzZGYiLCAibWV0aG9kIjogImFyaWEyLnRlbGxBY3RpdmUifV0%3D
  2506. JSON-RPC over WebSocket
  2507. ~~~~~~~~~~~~~~~~~~~~~~~
  2508. JSON-RPC over WebSocket uses same method signatures and response
  2509. format with JSON-RPC over HTTP. The supported WebSocket version is 13
  2510. which is detailed in :rfc:`6455`.
  2511. To send a RPC request to the RPC server, send serialized JSON string
  2512. in Text frame. The response from the RPC server is delivered also in
  2513. Text frame.
  2514. The RPC server will send the notification to the client. The
  2515. notification is unidirectional, therefore the client which received
  2516. the notification must not respond to it. The method signature of
  2517. notification is much like a normal method request but lacks id
  2518. key. The value associated by the params key is the data which this
  2519. notification carries. The format of this value varies depending on the
  2520. notification method. Following notification methods are defined.
  2521. .. function:: aria2.onDownloadStart(event)
  2522. This notification will be sent if a download is started.
  2523. The *event* is of type struct and it contains following keys.
  2524. The value type is string.
  2525. ``gid``
  2526. GID of the download.
  2527. .. function:: aria2.onDownloadPause(event)
  2528. This notification will be sent if a download is paused. The *event*
  2529. is the same struct of the *event* argument of
  2530. :func:`aria2.onDownloadStart` method.
  2531. .. function:: aria2.onDownloadStop(event)
  2532. This notification will be sent if a download is stopped by the user.
  2533. The *event* is the same struct of the *event* argument of
  2534. :func:`aria2.onDownloadStart` method.
  2535. .. function:: aria2.onDownloadComplete(event)
  2536. This notification will be sent if a download is completed. In
  2537. BitTorrent downloads, this notification is sent when the download is
  2538. completed and seeding is over. The *event* is the same struct of the
  2539. *event* argument of
  2540. :func:`aria2.onDownloadStart` method.
  2541. .. function:: aria2.onDownloadError(event)
  2542. This notification will be sent if a download is stopped due to error.
  2543. The *event* is the same struct of the *event* argument of
  2544. :func:`aria2.onDownloadStart` method.
  2545. .. function:: aria2.onBtDownloadComplete(event)
  2546. This notification will be sent if a download is completed in
  2547. BitTorrent (but seeding may not be over). The *event* is the same struct
  2548. of the *event* argument of
  2549. :func:`aria2.onDownloadStart` method.
  2550. Sample XML-RPC Client Code
  2551. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  2552. The following Ruby script adds ``http://localhost/aria2.tar.bz2`` to
  2553. aria2c operated on localhost with option :option:`--dir=/downloads <-d>` and
  2554. prints its reponse:
  2555. .. code-block:: ruby
  2556. #!/usr/bin/env ruby
  2557. require 'xmlrpc/client'
  2558. require 'pp'
  2559. client=XMLRPC::Client.new2("http://localhost:6800/rpc")
  2560. options={ "dir" => "/downloads" }
  2561. result=client.call("aria2.addUri", [ "http://localhost/aria2.tar.bz2" ], options)
  2562. pp result
  2563. If you are a Python lover, you can use xmlrpclib(for Python3.x, use
  2564. xmlrpc.client instead) to interact with aria2::
  2565. import xmlrpclib
  2566. from pprint import pprint
  2567. s = xmlrpclib.ServerProxy("http://localhost:6800/rpc")
  2568. r = s.aria2.addUri(["http://localhost/aria2.tar.bz2"], {"dir":"/downloads"})
  2569. pprint(r)
  2570. MISC
  2571. ----
  2572. Console Readout
  2573. ~~~~~~~~~~~~~~~
  2574. While downloading files, aria2 prints the console readout to tell the
  2575. progress of the downloads. The console readout is like this::
  2576. [#2089b0 400.0KiB/33.2MiB(1%) CN:1 DL:115.7KiB ETA:4m51s]
  2577. This section describes what these numbers and strings mean.
  2578. ``#NNNNNN``
  2579. The first 6 characters of GID in hex string. GID is an unique ID for
  2580. each download.
  2581. ``X/Y(Z%)``
  2582. Completed length, the total file length and its ratio. If
  2583. :option:`--select-file` is used, this is the sum of selected file.
  2584. ``SEED``
  2585. Share ratio. The client is now seeding. After BitTorrent download
  2586. finished, size information is replaced with this.
  2587. ``CN``
  2588. The number of connections the client has established.
  2589. ``SD``
  2590. The number of seeders the client is now connecting to.
  2591. ``DL``
  2592. Download speed (bytes per second).
  2593. ``UL``
  2594. Upload speed (bytes per second) and the number of uploaded bytes.
  2595. ``ETA``
  2596. Expected time to finish.
  2597. When more than 1 download are going on, some of the information
  2598. described above will be omitted in order to show several download
  2599. information. And the overall download and upload speed are shown at
  2600. the beginning of the line.
  2601. When aria2 is allocating file space or validating checksum, it
  2602. additionally prints the their progress:
  2603. FileAlloc
  2604. GID, allocated length and total length in bytes.
  2605. Checksum
  2606. GID, validated length and total length in bytes.
  2607. EXAMPLE
  2608. -------
  2609. HTTP/FTP Segmented Download
  2610. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2611. Download a file
  2612. ^^^^^^^^^^^^^^^
  2613. .. code-block:: console
  2614. $ aria2c "http://host/file.zip"
  2615. .. note::
  2616. 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.
  2617. Download a file from 2 different HTTP servers
  2618. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2619. .. code-block:: console
  2620. $ aria2c "http://host/file.zip" "http://mirror/file.zip"
  2621. Download a file from 1 host using 2 connections
  2622. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2623. .. code-block:: console
  2624. $ aria2c -x2 -k1M "http://host/file.zip"
  2625. Download a file from HTTP and FTP servers
  2626. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2627. .. code-block:: console
  2628. $ aria2c "http://host1/file.zip" "ftp://host2/file.zip"
  2629. Download files listed in a text file concurrently
  2630. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2631. .. code-block:: console
  2632. $ aria2c -ifiles.txt -j2
  2633. .. note::
  2634. -j option specifies the number of parallel downloads.
  2635. Using proxy
  2636. ^^^^^^^^^^^
  2637. For HTTP:
  2638. .. code-block:: console
  2639. $ aria2c --http-proxy="http://proxy:8080" "http://host/file"
  2640. .. code-block:: console
  2641. $ aria2c --http-proxy="http://proxy:8080" --no-proxy="localhost,127.0.0.1,192.168.0.0/16" "http://host/file"
  2642. For FTP:
  2643. .. code-block:: console
  2644. $ aria2c --ftp-proxy="http://proxy:8080" "ftp://host/file"
  2645. .. note::
  2646. See :option:`--http-proxy`, :option:`--https-proxy`, :option:`--ftp-proxy`, :option:`--all-proxy` and
  2647. :option:`--no-proxy` for details. You can specify proxy in the environment
  2648. variables. See `ENVIRONMENT`_ section.
  2649. Proxy with authorization
  2650. ^^^^^^^^^^^^^^^^^^^^^^^^
  2651. .. code-block:: console
  2652. $ aria2c --http-proxy="http://username:password@proxy:8080" "http://host/file"
  2653. .. code-block:: console
  2654. $ aria2c --http-proxy="http://proxy:8080" --http-proxy-user="username" --http-proxy-passwd="password" "http://host/file"
  2655. Metalink Download
  2656. ~~~~~~~~~~~~~~~~~
  2657. Download files with remote Metalink
  2658. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2659. .. code-block:: console
  2660. $ aria2c --follow-metalink=mem "http://host/file.metalink"
  2661. Download using a local metalink file
  2662. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2663. .. code-block:: console
  2664. $ aria2c -p --lowest-speed-limit=4000 file.metalink
  2665. .. note::
  2666. To stop a download, press :kbd:`Ctrl-C`.
  2667. You can resume the transfer by running aria2c with the same argument in the same
  2668. directory.
  2669. Download several local metalink files
  2670. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2671. .. code-block:: console
  2672. $ aria2c -j2 file1.metalink file2.metalink
  2673. Download only selected files using index
  2674. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2675. .. code-block:: console
  2676. $ aria2c --select-file=1-4,8 file.metalink
  2677. .. note::
  2678. The index is printed to the console using -S option.
  2679. Download a file using a local metalink file with user preference
  2680. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2681. .. code-block:: console
  2682. $ aria2c --metalink-location=jp,us --metalink-version=1.1 --metalink-language=en-US file.metalink
  2683. BitTorrent Download
  2684. ~~~~~~~~~~~~~~~~~~~
  2685. Download files from remote BitTorrent file
  2686. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2687. .. code-block:: console
  2688. $ aria2c --follow-torrent=mem "http://host/file.torrent"
  2689. Download using a local torrent file
  2690. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2691. .. code-block:: console
  2692. $ aria2c --max-upload-limit=40K file.torrent
  2693. .. note::
  2694. --max-upload-limit specifies the max of upload rate.
  2695. .. note::
  2696. To stop a download, press :kbd:`Ctrl-C`. You can resume the transfer by running aria2c with the same argument in the same directory.
  2697. Download using BitTorrent Magnet URI
  2698. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2699. .. code-block:: console
  2700. $ aria2c "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C&dn=aria2"
  2701. .. note::
  2702. Don't forget to quote BitTorrent Magnet URI which includes ``&``
  2703. character with single(``'``) or double(``"``) quotation.
  2704. Download 2 torrents
  2705. ^^^^^^^^^^^^^^^^^^^
  2706. .. code-block:: console
  2707. $ aria2c -j2 file1.torrent file2.torrent
  2708. Download a file using torrent and HTTP/FTP server
  2709. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2710. .. code-block:: console
  2711. $ aria2c -Ttest.torrent "http://host1/file" "ftp://host2/file"
  2712. .. note::
  2713. Downloading multi file torrent with HTTP/FTP is not supported.
  2714. Download only selected files using index(usually called "selectable download")
  2715. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2716. .. code-block:: console
  2717. $ aria2c --select-file=1-4,8 file.torrent
  2718. .. note::
  2719. The index is printed to the console using -S option.
  2720. Download .torrent file, but do not download its contents
  2721. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2722. .. code-block:: console
  2723. $ aria2c --follow-torrent=false "http://host/file.torrent"
  2724. Specify output filename
  2725. ^^^^^^^^^^^^^^^^^^^^^^^
  2726. To specify output filename for BitTorrent downloads, you need to know
  2727. the index of file in torrent file using :option:`--show-files <-S>` option. For example, the
  2728. output looks like this::
  2729. idx|path/length
  2730. ===+======================
  2731. 1|dist/base-2.6.18.iso
  2732. |99.9MiB
  2733. ---+----------------------
  2734. 2|dist/driver-2.6.18.iso
  2735. |169.0MiB
  2736. ---+----------------------
  2737. To save 'dist/base-2.6.18.iso' in '/tmp/mydir/base.iso' and
  2738. 'dist/driver-2.6.18.iso' in '/tmp/dir/driver.iso', use the following
  2739. command:
  2740. .. code-block:: console
  2741. $ aria2c --dir=/tmp --index-out=1=mydir/base.iso --index-out=2=dir/driver.iso file.torrent
  2742. Change the listening port for incoming peer
  2743. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2744. .. code-block:: console
  2745. $ aria2c --listen-port=7000-7001,8000 file.torrent
  2746. .. note::
  2747. Since aria2 doesn't configure firewall or router for port forwarding, it's up
  2748. to you to do it manually.
  2749. Specify the condition to stop program after torrent download finished
  2750. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2751. .. code-block:: console
  2752. $ aria2c --seed-time=120 --seed-ratio=1.0 file.torrent
  2753. .. note::
  2754. In the above example, the program exits when the 120 minutes has elapsed since download completed or seed ratio reaches 1.0.
  2755. Throttle upload speed
  2756. ^^^^^^^^^^^^^^^^^^^^^
  2757. .. code-block:: console
  2758. $ aria2c --max-upload-limit=100K file.torrent
  2759. Enable IPv4 DHT
  2760. ^^^^^^^^^^^^^^^
  2761. .. code-block:: console
  2762. $ aria2c --enable-dht --dht-listen-port=6881 file.torrent
  2763. .. note::
  2764. DHT uses udp port. Since aria2 doesn't configure firewall or router for port
  2765. forwarding, it's up to you to do it manually.
  2766. Enable IPv6 DHT
  2767. ^^^^^^^^^^^^^^^
  2768. .. code-block:: console
  2769. $ aria2c --enable-dht6 --dht-listen-port=6881 --dht-listen-addr6=YOUR_GLOBAL_UNICAST_IPV6_ADDR
  2770. .. note::
  2771. aria2 shares same port between IPv4 and IPv6 DHT.
  2772. Add and remove tracker URI
  2773. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  2774. Removes all tracker announce URIs described in file.torrent and use
  2775. ``http://tracker1/announce`` and ``http://tracker2/announce`` instead:
  2776. .. code-block:: console
  2777. $ aria2c --bt-exclude-tracker="*" --bt-tracker="http://tracker1/announce,http://tracker2/announce" file.torrent
  2778. More advanced HTTP features
  2779. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2780. Load cookies
  2781. ^^^^^^^^^^^^
  2782. .. code-block:: console
  2783. $ aria2c --load-cookies=cookies.txt "http://host/file.zip"
  2784. .. note::
  2785. You can use Firefox/Mozilla/Chromium's cookie file without modification.
  2786. Resume download started by web browsers or another programs
  2787. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2788. .. code-block:: console
  2789. $ aria2c -c -s2 "http://host/partiallydownloadedfile.zip"
  2790. Client certificate authorization for SSL/TLS
  2791. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2792. .. code-block:: console
  2793. $ aria2c --certificate=/path/to/mycert.pem --private-key=/path/to/mykey.pem https://host/file
  2794. .. note::
  2795. The file specified in :option:`--private-key` must be decrypted. The behavior when
  2796. encrypted one is given is undefined.
  2797. Verify peer in SSL/TLS using given CA certificates
  2798. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2799. .. code-block:: console
  2800. $ aria2c --ca-certificate=/path/to/ca-certificates.crt --check-certificate https://host/file
  2801. RPC
  2802. ~~~
  2803. Encrypt RPC transport by SSL/TLS
  2804. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2805. Specify server certificate file and private key file as follows:
  2806. .. code-block:: console
  2807. $ aria2c --enable-rpc --rpc-certificate=/path/to/server.crt --rpc-private-key=/path/to/server.key --rpc-secure
  2808. And more advanced features
  2809. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  2810. Throttle download speed
  2811. ^^^^^^^^^^^^^^^^^^^^^^^
  2812. .. code-block:: console
  2813. $ aria2c --max-download-limit=100K file.metalink
  2814. Repair a damaged download
  2815. ^^^^^^^^^^^^^^^^^^^^^^^^^
  2816. .. code-block:: console
  2817. $ aria2c -V file.metalink
  2818. .. note::
  2819. Repairing damaged downloads can be done efficiently when used with
  2820. BitTorrent or Metalink with chunk checksums.
  2821. Drop connection if download speed is lower than specified value
  2822. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2823. .. code-block:: console
  2824. $ aria2c --lowest-speed-limit=10K file.metalink
  2825. Parameterized URI support
  2826. ^^^^^^^^^^^^^^^^^^^^^^^^^
  2827. You can specify set of parts:
  2828. .. code-block:: console
  2829. $ aria2c -P "http://{host1,host2,host3}/file.iso"
  2830. You can specify numeric sequence:
  2831. .. code-block:: console
  2832. $ aria2c -Z -P "http://host/image[000-100].png"
  2833. .. note::
  2834. -Z option is required if the all URIs don't point to the same file, such as the above example.
  2835. You can specify step counter:
  2836. .. code-block:: console
  2837. $ aria2c -Z -P "http://host/image[A-Z:2].png"
  2838. Verify checksum
  2839. ^^^^^^^^^^^^^^^
  2840. .. code-block:: console
  2841. $ aria2c --checksum=sha-1=0192ba11326fe2298c8cb4de616f4d4140213837 http://example.org/file
  2842. Parallel downloads of arbitrary number of URI,metalink,torrent
  2843. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2844. .. code-block:: console
  2845. $ aria2c -j3 -Z "http://host/file1" file2.torrent file3.metalink
  2846. BitTorrent Encryption
  2847. ^^^^^^^^^^^^^^^^^^^^^
  2848. Encrypt whole payload using ARC4:
  2849. .. code-block:: console
  2850. $ aria2c --bt-min-crypto-level=arc4 --bt-require-crypto=true file.torrent
  2851. SEE ALSO
  2852. --------
  2853. Project Web Site: http://aria2.sourceforge.net/
  2854. aria2 Wiki: http://sourceforge.net/apps/trac/aria2/wiki
  2855. Metalink Homepage: http://www.metalinker.org/
  2856. The Metalink Download Description Format: :rfc:`5854`
  2857. COPYRIGHT
  2858. ---------
  2859. Copyright (C) 2006, 2013 Tatsuhiro Tsujikawa
  2860. This program is free software; you can redistribute it and/or modify
  2861. it under the terms of the GNU General Public License as published by
  2862. the Free Software Foundation; either version 2 of the License, or
  2863. (at your option) any later version.
  2864. This program is distributed in the hope that it will be useful,
  2865. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2866. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2867. GNU General Public License for more details.
  2868. You should have received a copy of the GNU General Public License
  2869. along with this program; if not, write to the Free Software
  2870. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2871. In addition, as a special exception, the copyright holders give
  2872. permission to link the code of portions of this program with the
  2873. OpenSSL library under certain conditions as described in each
  2874. individual source file, and distribute linked combinations
  2875. including the two.
  2876. You must obey the GNU General Public License in all respects
  2877. for all of the code used other than OpenSSL. If you modify
  2878. file(s) with this exception, you may extend this exception to your
  2879. version of the file(s), but you are not obligated to do so. If you
  2880. do not wish to do so, delete this exception statement from your
  2881. version. If you delete this exception statement from all source
  2882. files in the program, then also delete it here.