标签 aria2 下的文章

“”

安装aria2

sudo apt install aria2

启动aria2

aria2c --conf-path=/etc/.aria2/aria2c.conf -D

aria2c.conf看这里https://github.com/P3TERX/aria2.conf

aria2 下载示例

aria2c 'magnet:?xt=urn:btih:6e9f28f581fcec156cb3453caf477e4fabf45b5e&dn=%EA%B7%80%EB%A9%B8%EC%9D%98+%EC%B9%BC%EB%82%A0+%EB%82%A8%EB%A7%A4%EC%9D%98+%EC%97%B0%EC%83%81%EC%98%81%EC%A4%91+Demon+Slayer+Kimetsu+no+Yaiba+SIBLINGS+BOND.2021.1080p.KOR.FHDRip.H264.AAC-JTC.mkv&xl=2464537015&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://tracker.opentrackr.org:1337/announce'

aria2c rpc 下载示例

curl -v -X POST -d '{"jsonrpc": "2.0", "id": "const","method": "aria2.addUri", "params": ["token:P3TERX",["magnet:?xt=urn:btih:6e9f28f581fcec156cb3453caf477e4fabf45b5e&dn=%EA%B7%80%EB%A9%B8%EC%9D%98+%EC%B9%BC%EB%82%A0+%EB%82%A8%EB%A7%A4%EC%9D%98+%EC%97%B0%EC%83%81%EC%98%81%EC%A4%91+Demon+Slayer+Kimetsu+no+Yaiba+SIBLINGS+BOND.2021.1080p.KOR.FHDRip.H264.AAC-JTC.mkv&xl=2464537015&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://tracker.opentrackr.org:1337/announce"],{"out":"","dir":"/home/pi/down/"}]}' http://localhost:6800/jsonrpc

命令执行结果:

{"id":"const","jsonrpc":"2.0","result":"24cd0ec304ff6820"}

aria2c 继续下载
 当aria2c异常退出时,或者手动退出时,使用相同的命令就可以继续下载了。通过相同的命令重新启动aria,它将正确地恢复下载。前提是有按照aria2c.conf中保存了aria2.session.

aria2c 'magnet:?xt=urn:btih:5813fb39c0bd2e70efbeef2f37ac61a5ec0c80aa&dn=%EC%9C%A0%EC%B2%B4%EC%9D%B4%ED%83%88%EC%9E%90+Spiritwalker%2C2021.1080p.FHDRip.H264.AAC-NonDRM&xl=3374432532&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://tracker.opentrackr.org:1337/announce'

aria2c rcp 示例
最全的说明,肯定是官方的文档 https://aria2.github.io/manual/en/html/aria2c.html
The following example adds http://example.org/file:

import urllib2, json
jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
                      'method':'aria2.addUri',
                      'params':[['http://example.org/file']]})
c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
c.read()
'{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'

使用curl命令行操作

curl -v -d '{"jsonrpc":"2.0", "id":"qwer","method":"aria2.addUri","params":["token:const",["http://example.org/file"]]}' http://localhost:6800/jsonrpc

{"id":"qwer","jsonrpc":"2.0","result":"6d6994d4933bd2af"}

aria2c 删除下载任务aria2.remove
This method removes the download denoted by gid (string). If the specified download is in progress, it is first stopped. The status of the removed download becomes removed. This method returns GID of removed download.

The following examples remove a download with GID#2089b05ecca3d829.

JSON-RPC Example

import urllib2, json
jsonreq = json.dumps({'jsonrpc':'2.0', 'id':'qwer',
                      'method':'aria2.remove',
                      'params':['2089b05ecca3d829']})
c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
c.read()
'{"id":"qwer","jsonrpc":"2.0","result":"2089b05ecca3d829"}'

aria2c rpc 常用命令
aria2.addTorrent
aria2.addMetalink
aria2.remove
aria2.forceRemove
aria2.pause
aria2.pauseAll
aria2.forcePause
aria2.forcePauseAll
aria2.unpause
aria2.unpauseAll
aria2.tellStatus
aria2.getUris
This method returns the URIs used in the download denoted by gid (string). The response is an array of structs and it contains following keys. Values are string.
aria2.getFiles
This method returns the file list of the download denoted by gid (string). The response is an array of structs which contain following keys. Values are strings.
aria2.getPeers
This method returns a list peers of the download denoted by gid (string). This method is for BitTorrent only. The response is an array of structs and contains the following keys. Values are strings.
aria2.getServers
This method returns currently connected HTTP(S)/FTP/SFTP servers of the download denoted by gid (string). The response is an array of structs and contains the following keys. Values are strings.
aria2.tellActive
This method returns a list of active downloads. The response is an array of the same structs as returned by the aria2.tellStatus() method. For the keys parameter, please refer to the aria2.tellStatus() method.

aria2.tellWaiting
This method returns a list of waiting downloads, including paused ones. offset is an integer and specifies the offset from the download waiting at the front. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the aria2.tellStatus() method.
aria2.tellStopped
This method returns a list of stopped downloads. offset is an integer and specifies the offset from the least recently stopped download. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the aria2.tellStatus() method.
aria2.changePosition
This method changes the position of the download denoted by gid in the queue. pos is an integer. how is a string. If how is POS_SET, it moves the download to a position relative to the beginning of the queue. If how is POS_CUR, it moves the download to a position relative to the current position. If how is POS_END, it moves the download to a position relative to the end of the queue. If the destination position is less than 0 or beyond the end of the queue, it moves the download to the beginning or the end of the queue respectively. The response is an integer denoting the resulting position.
aria2.changeUri
This method removes the URIs in delUris from and appends the URIs in addUris to download denoted by gid. delUris and addUris are lists of strings. A download can contain multiple files and URIs are attached to each file.
aria2.getOption
This method returns options of the download denoted by gid. The response is a struct where keys are the names of options. The values are strings. Note that this method does not return options which have no default value and have not been set on the command-line, in configuration files or RPC methods.
aria2.changeOption
This method changes options of the download denoted by gid (string) dynamically. options is a struct.
aria2.getGlobalOption
This method returns the global options.
aria2.changeGlobalOption
This method changes global options dynamically.
aria2.getGlobalStat
This method returns global statistics such as the overall download and upload speeds.
curl 命令示例

curl -d '{"jsonrpc":"2.0", "id":"qwer","method":"aria2.getGlobalStat","params":["token:P3TERX"]}' http://localhost:6800/jsonrpc

{"id":"qwer","jsonrpc":"2.0","result":{"downloadSpeed":"0","numActive":"0","numStopped":"5","numStoppedTotal":"5","numWaiting":"0","uploadSpeed":"0"}}

aria2.purgeDownloadResult
This method purges completed/error/removed downloads to free memory.
aria2.removeDownloadResult
This method removes a completed/error/removed download denoted by gid from memory.
aria2.getVersion
This method returns the version of aria2 and the list of enabled features.
aria2.getSessionInfo
This method returns session information.
aria2.shutdown
This method shuts down aria2. This method returns OK.

aria2.forceShutdown
This method shuts down aria2(). This method behaves like :func:'aria2.shutdown` without performing any actions which take time, such as contacting BitTorrent trackers to unregister downloads first. This method returns OK.

aria2.saveSession
This method saves the current session to a file specified by the --save-session option. This method returns OK if it succeeds.

system.multicall
This methods encapsulates multiple method calls in a single request.

system.listMethods()
This method returns all the available RPC methods in an array of string.
system.listNotifications()
This method returns all the available RPC notifications in an array of string.

aria2c xmlrpc 示例
xmlrpc 地址:http://localhost:6800/rpc

aria2c 下载命令汇总

Download a file from two different HTTP servers¶

 aria2c "http://host/file.zip" "http://mirror/file.zip"

Download a file from one host using multiple connections¶

 aria2c -x2 -k1M "http://host/file.zip"

Note

The -x option specified the number of allowed connections, while the -k option specified the size of chunks.

Download a file from HTTP and FTP servers at the same time¶

 aria2c "http://host1/file.zip" "ftp://host2/file.zip"

Download files listed in a text file concurrently¶

 aria2c -ifiles.txt -j2

Using a proxy¶
For HTTP:

 aria2c --http-proxy="http://proxy:8080" "http://host/file"
 aria2c --http-proxy="http://proxy:8080" --no-proxy="localhost,127.0.0.1,192.168.0.0/16" "http://host/file"

For FTP:

 aria2c --ftp-proxy="http://proxy:8080" "ftp://host/file"

Note

See --http-proxy, --https-proxy, --ftp-proxy, --all-proxy and --no-proxy for details. You can specify proxy in the environment variables. See ENVIRONMENT section.

Using a Proxy with authorization¶

 aria2c --http-proxy="http://username:password@proxy:8080" "http://host/file"
 aria2c --http-proxy="http://proxy:8080" --http-proxy-user="username" --http-proxy-passwd="password" "http://host/file"

Metalink Download¶
Download files with remote Metalink¶

 aria2c --follow-metalink=mem "http://host/file.metalink"

Download using a local metalink file¶

 aria2c -p --lowest-speed-limit=4000 file.metalink

Note

To stop a download, press Ctrl-C. You can resume the transfer by running aria2c with the same argument in the same directory.

Download several local metalink files¶

 aria2c -j2 file1.metalink file2.metalink

Download only selected files¶

 aria2c --select-file=1-4,8 file.metalink

Note

The index is printed to the console using -S option.

Download a file using a local metalink file with user preference¶

 aria2c --metalink-location=jp,us --metalink-version=1.1 --metalink-language=en-US file.metalink

BitTorrent Download¶
Download files using a remote BitTorrent file¶

 aria2c --follow-torrent=mem "http://host/file.torrent"

Download using a local torrent file¶

 aria2c --max-upload-limit=40K file.torrent

Note

To stop a download, press Ctrl-C. You can resume the transfer later by running aria2c with the same argument in the same directory.

Download using BitTorrent Magnet URI¶

 aria2c "magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C&dn=aria2"

Note

Don't forget to quote BitTorrent Magnet URIs which include & characters with single(') or double(") quotes when specifying URIs on the command-line.

Download 2 torrents¶

 aria2c -j2 file1.torrent file2.torrent

Download a file via torrent and HTTP/FTP server in parallel¶

 aria2c -Ttest.torrent "http://host1/file" "ftp://host2/file"

Only download specific files (usually called "selected download")¶

 aria2c --select-file=1-4,8 file.torrent

Note

The index is printed to the console using -S option.

Download a .torrent file, but do not download the torrent¶

 aria2c --follow-torrent=false "http://host/file.torrent"