win10 aria2c下载器的简单使用指南,配置文件

win10 aria2c下载器的简单使用指南,配置文件

​ 最近几个月经常使用youtube-dl下载youtube上面的视频,因为国内的网络环境不太好,用youtube-dl经常会突然断开,并且下载速度也得不到保证,所以就想到了youtube-dl可以使用外置下载工具,其中httpie,wget,curl,还有aria2c我是知道的。httpie和aria2c这两个工具是跨平台的,不过httpie主要用途并不是下载,所以这里我们用专业的下载器aria2c。

01.帮助信息

aria2c.exe -h查看帮助信息

这里给选项的帮助信息都分好类了,十分方便查看。

aria2c.exe -h
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
Printing options tagged with '#basic'.
See 'aria2c -h#help' to know all available tags.
Options:
 -v, --version                Print the version number and exit.

                              Tags: #basic

 -h, --help[=TAG|KEYWORD]     Print usage and exit.
                              The help messages are classified with tags. A tag
                              starts with "#". For example, type "--help=#http"
                              to get the usage for the options tagged with
                              "#http". If non-tag word is given, print the usage
                              for the options whose name includes that word.

                              Possible Values: #basic, #advanced, #http, #https, #ftp, #metalink, #bittorrent, #cookie, #hook, #file, #rpc, #checksum, #experimental, #deprecated, #help, #all
                              Default: #basic
                              Tags: #basic, #help

 -l, --log=LOG                The file name of the log file. If '-' is
                              specified, log is written to stdout.

                              Possible Values: /path/to/file, -
                              Tags: #basic

 -d, --dir=DIR                The directory to store the downloaded file.

                              Possible Values: /path/to/directory
                              Default: D:\BaiduNetdiskDownload\生放送\高倉むきASMR
                              Tags: #basic, #file

 -o, --out=FILE               The file name of the downloaded file. It is
                              always relative to the directory given in -d
                              option. When the -Z option is used, this option
                              will be ignored.

                              Possible Values: /path/to/file
                              Tags: #basic, #http, #ftp, #file

 -s, --split=N                Download a file using N connections. If more
                              than N URIs are given, first N URIs are used and
                              remaining URLs are used for backup. If less than
                              N URIs are given, those URLs are used more than
                              once so that N connections total are made
                              simultaneously. The number of connections to the
                              same host is restricted by the
                              --max-connection-per-server option. See also the
                              --min-split-size option.

                              Possible Values: 1-*
                              Default: 5
                              Tags: #basic, #http, #ftp

 --file-allocation=METHOD     Specify file allocation method.
                              'none' doesn't pre-allocate file space. 'prealloc'
                              pre-allocates file space before download begins.
                              This may take some time depending on the size of
                              the file.
                              If you are using newer file systems such as ext4
                              (with extents support), btrfs, xfs or NTFS
                              (MinGW build only), 'falloc' is your best
                              choice. It allocates large(few GiB) files
                              almost instantly. Don't use 'falloc' with legacy
                              file systems such as ext3 and FAT32 because it
                              takes almost same time as 'prealloc' and it
                              blocks aria2 entirely until allocation finishes.
                              'falloc' may not be available if your system
                              doesn't have posix_fallocate() function.
                              'trunc' uses ftruncate() system call or
                              platform-specific counterpart to truncate a file
                              to a specified length.

                              Possible Values: none, prealloc, trunc, falloc
                              Default: prealloc
                              Tags: #basic, #file

 -V, --check-integrity[=true|false] Check file integrity by validating piece
                              hashes or a hash of entire file. This option has
                              effect only in BitTorrent, Metalink downloads
                              with checksums or HTTP(S)/FTP downloads with
                              --checksum option. If piece hashes are provided,
                              this option can detect damaged portions of a file
                              and re-download them. If a hash of entire file is
                              provided, hash check is only done when file has
                              been already download. This is determined by file
                              length. If hash check fails, file is
                              re-downloaded from scratch. If both piece hashes
                              and a hash of entire file are provided, only
                              piece hashes are used.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #metalink, #bittorrent, #file, #checksum

 -c, --continue[=true|false]  Continue downloading a partially downloaded
                              file. Use this option to resume a download
                              started by a web browser or another program
                              which downloads files sequentially from the
                              beginning. Currently this option is only
                              applicable to http(s)/ftp downloads.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #http, #ftp

 -i, --input-file=FILE        Downloads URIs found in FILE. You can specify
                              multiple URIs for a single entity: separate
                              URIs on a single line using the TAB character.
                              Reads input from stdin when '-' is specified.
                              Additionally, options can be specified after each
                              line of URI. This optional line must start with
                              one or more white spaces and have one option per
                              single line. See INPUT FILE section of man page
                              for details. See also --deferred-input option.

                              Possible Values: /path/to/file, -
                              Tags: #basic

 -j, --max-concurrent-downloads=N Set maximum number of parallel downloads for
                              every static (HTTP/FTP) URL, torrent and metalink.
                              See also --split and --optimize-concurrent-downloads options.

                              Possible Values: 1-*
                              Default: 5
                              Tags: #basic

 -Z, --force-sequential[=true|false] Fetch URIs in the command-line sequentially
                              and download each URI in a separate session, like
                              the usual command-line download utilities.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic

 -x, --max-connection-per-server=NUM The maximum number of connections to one
                              server for each download.

                              Possible Values: 1-16
                              Default: 1
                              Tags: #basic, #http, #ftp

 -k, --min-split-size=SIZE    aria2 does not split less than 2*SIZE byte range.
                              For example, let's consider downloading 20MiB
                              file. If SIZE is 10M, aria2 can split file into 2
                              range [0-10MiB) and [10MiB-20MiB) and download it
                              using 2 sources(if --split >= 2, of course).
                              If SIZE is 15M, since 2*15M > 20MiB, aria2 does
                              not split file and download it using 1 source.
                              You can append K or M(1K = 1024, 1M = 1024K).

                              Possible Values: 1048576-1073741824
                              Default: 20M
                              Tags: #basic, #http, #ftp

 --ftp-user=USER              Set FTP user. This affects all URLs.

                              Tags: #basic, #ftp

 --ftp-passwd=PASSWD          Set FTP password. This affects all URLs.

                              Tags: #basic, #ftp

 --http-user=USER             Set HTTP user. This affects all URLs.

                              Tags: #basic, #http

 --http-passwd=PASSWD         Set HTTP password. This affects all URLs.

                              Tags: #basic, #http

 --load-cookies=FILE          Load Cookies from FILE using the Firefox3 format
                              and Mozilla/Firefox(1.x/2.x)/Netscape format.

                              Possible Values: /path/to/file
                              Tags: #basic, #http, #cookie

 -S, --show-files[=true|false] Print file listing of .torrent, .meta4 and
                              .metalink file and exit. More detailed
                              information will be listed in case of torrent
                              file.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #metalink, #bittorrent

 --max-overall-upload-limit=SPEED Set max overall upload speed in bytes/sec.
                              0 means unrestricted.
                              You can append K or M(1K = 1024, 1M = 1024K).
                              To limit the upload speed per torrent, use
                              --max-upload-limit option.

                              Possible Values: 0-*
                              Default: 0
                              Tags: #basic, #bittorrent

 -u, --max-upload-limit=SPEED Set max upload speed per each torrent in
                              bytes/sec. 0 means unrestricted.
                              You can append K or M(1K = 1024, 1M = 1024K).
                              To limit the overall upload speed, use
                              --max-overall-upload-limit option.

                              Possible Values: 0-*
                              Default: 0
                              Tags: #basic, #bittorrent

 -T, --torrent-file=TORRENT_FILE  The path to the .torrent file.

                              Possible Values: /path/to/file
                              Tags: #basic, #bittorrent

 --listen-port=PORT...        Set TCP port number for BitTorrent downloads.
                              Multiple ports can be specified by using ',',
                              for example: "6881,6885". You can also use '-'
                              to specify a range: "6881-6999". ',' and '-' can
                              be used together.

                              Possible Values: 1024-65535
                              Default: 6881-6999
                              Tags: #basic, #bittorrent

 --enable-dht[=true|false]    Enable IPv4 DHT functionality. It also enables
                              UDP tracker support. If a private flag is set
                              in a torrent, aria2 doesn't use DHT for that
                              download even if ``true`` is given.

                              Possible Values: true, false
                              Default: true
                              Tags: #basic, #bittorrent

 --dht-listen-port=PORT...    Set UDP listening port used by DHT(IPv4, IPv6)
                              and UDP tracker. Multiple ports can be specified
                              by using ',', for example: "6881,6885". You can
                              also use '-' to specify a range: "6881-6999".
                              ',' and '-' can be used together.

                              Possible Values: 1024-65535
                              Default: 6881-6999
                              Tags: #basic, #bittorrent

 --enable-dht6[=true|false]   Enable IPv6 DHT functionality.
                              Use --dht-listen-port option to specify port
                              number to listen on. See also --dht-listen-addr6
                              option.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #bittorrent

 --dht-listen-addr6=ADDR      Specify address to bind socket for IPv6 DHT.
                              It should be a global unicast IPv6 address of the
                              host.

                              Tags: #basic, #bittorrent

 -M, --metalink-file=METALINK_FILE The file path to the .meta4 and .metalink
                              file. Reads input from stdin when '-' is
                              specified.

                              Possible Values: /path/to/file, -
                              Tags: #basic, #metalink

URI, MAGNET, TORRENT_FILE, METALINK_FILE:
 You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z option, all
 URIs must point to the same file or downloading will fail.
 You can also specify arbitrary number of BitTorrent Magnet URIs, torrent/
 metalink files stored in a local drive. Please note that they are always
 treated as a separate download.

 You can specify both torrent file with -T option and URIs. By doing this,
 download a file from both torrent swarm and HTTP/FTP server at the same time,
 while the data from HTTP/FTP are uploaded to the torrent swarm. For single file
 torrents, URI can be a complete URI pointing to the resource or if URI ends
 with '/', 'name' in torrent file is added. For multi-file torrents, 'name' and
 'path' in torrent are added to form a URI for each file.

 Make sure that URI is quoted with single(') or double(") quotation if it
 contains "&" or any characters that have special meaning in shell.

About the number of connections
 Since 1.10.0 release, aria2 uses 1 connection per host by default and has 20MiB
 segment size restriction. So whatever value you specify using -s option, it
 uses 1 connection per host. To make it behave like 1.9.x, use
 --max-connection-per-server=4 --min-split-size=1M.

Refer to man page for more information.

aria2c -h#help,输出所有支持的#tag。

我们发现支持这么多tag,这样我们查看对应的帮助信息的时候就会比较方便

basic, #advanced, #http, #https, #ftp, #metalink, #bittorrent, #cookie, #hook, #file, #rpc, #checksum

aria2c.exe -h#help
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
Printing options tagged with '#help'.
See 'aria2c -h#help' to know all available tags.
Options:
 -h, --help[=TAG|KEYWORD]     Print usage and exit.
                              The help messages are classified with tags. A tag
                              starts with "#". For example, type "--help=#http"
                              to get the usage for the options tagged with
                              "#http". If non-tag word is given, print the usage
                              for the options whose name includes that word.

                              Possible Values: #basic, #advanced, #http, #https, #ftp, #metalink, #bittorrent, #cookie, #hook, #file, #rpc, #checksum, #experimental, #deprecated, #help, #all
                              Default: #basic
                              Tags: #basic, #help

Refer to man page for more information.

02.basic

输入aria2c -h#basic可以查看basic tag下的选项,也就是一些基础选项

aria2c.exe -h#basic
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
Printing options tagged with '#basic'.
See 'aria2c -h#help' to know all available tags.
Options:
 -v, --version                Print the version number and exit.

                              Tags: #basic

 -h, --help[=TAG|KEYWORD]     Print usage and exit.
                              The help messages are classified with tags. A tag
                              starts with "#". For example, type "--help=#http"
                              to get the usage for the options tagged with
                              "#http". If non-tag word is given, print the usage
                              for the options whose name includes that word.

                              Possible Values: #basic, #advanced, #http, #https, #ftp, #metalink, #bittorrent, #cookie, #hook, #file, #rpc, #checksum, #experimental, #deprecated, #help, #all
                              Default: #basic
                              Tags: #basic, #help

 -l, --log=LOG                The file name of the log file. If '-' is
                              specified, log is written to stdout.

                              Possible Values: /path/to/file, -
                              Tags: #basic

 -d, --dir=DIR                The directory to store the downloaded file.

                              Possible Values: /path/to/directory
                              Default: D:\BaiduNetdiskDownload\生放送\高倉むきASMR
                              Tags: #basic, #file

 -o, --out=FILE               The file name of the downloaded file. It is
                              always relative to the directory given in -d
                              option. When the -Z option is used, this option
                              will be ignored.

                              Possible Values: /path/to/file
                              Tags: #basic, #http, #ftp, #file

 -s, --split=N                Download a file using N connections. If more
                              than N URIs are given, first N URIs are used and
                              remaining URLs are used for backup. If less than
                              N URIs are given, those URLs are used more than
                              once so that N connections total are made
                              simultaneously. The number of connections to the
                              same host is restricted by the
                              --max-connection-per-server option. See also the
                              --min-split-size option.

                              Possible Values: 1-*
                              Default: 5
                              Tags: #basic, #http, #ftp

 --file-allocation=METHOD     Specify file allocation method.
                              'none' doesn't pre-allocate file space. 'prealloc'
                              pre-allocates file space before download begins.
                              This may take some time depending on the size of
                              the file.
                              If you are using newer file systems such as ext4
                              (with extents support), btrfs, xfs or NTFS
                              (MinGW build only), 'falloc' is your best
                              choice. It allocates large(few GiB) files
                              almost instantly. Don't use 'falloc' with legacy
                              file systems such as ext3 and FAT32 because it
                              takes almost same time as 'prealloc' and it
                              blocks aria2 entirely until allocation finishes.
                              'falloc' may not be available if your system
                              doesn't have posix_fallocate() function.
                              'trunc' uses ftruncate() system call or
                              platform-specific counterpart to truncate a file
                              to a specified length.

                              Possible Values: none, prealloc, trunc, falloc
                              Default: prealloc
                              Tags: #basic, #file

 -V, --check-integrity[=true|false] Check file integrity by validating piece
                              hashes or a hash of entire file. This option has
                              effect only in BitTorrent, Metalink downloads
                              with checksums or HTTP(S)/FTP downloads with
                              --checksum option. If piece hashes are provided,
                              this option can detect damaged portions of a file
                              and re-download them. If a hash of entire file is
                              provided, hash check is only done when file has
                              been already download. This is determined by file
                              length. If hash check fails, file is
                              re-downloaded from scratch. If both piece hashes
                              and a hash of entire file are provided, only
                              piece hashes are used.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #metalink, #bittorrent, #file, #checksum

 -c, --continue[=true|false]  Continue downloading a partially downloaded
                              file. Use this option to resume a download
                              started by a web browser or another program
                              which downloads files sequentially from the
                              beginning. Currently this option is only
                              applicable to http(s)/ftp downloads.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #http, #ftp

 -i, --input-file=FILE        Downloads URIs found in FILE. You can specify
                              multiple URIs for a single entity: separate
                              URIs on a single line using the TAB character.
                              Reads input from stdin when '-' is specified.
                              Additionally, options can be specified after each
                              line of URI. This optional line must start with
                              one or more white spaces and have one option per
                              single line. See INPUT FILE section of man page
                              for details. See also --deferred-input option.

                              Possible Values: /path/to/file, -
                              Tags: #basic

 -j, --max-concurrent-downloads=N Set maximum number of parallel downloads for
                              every static (HTTP/FTP) URL, torrent and metalink.
                              See also --split and --optimize-concurrent-downloads options.

                              Possible Values: 1-*
                              Default: 5
                              Tags: #basic

 -Z, --force-sequential[=true|false] Fetch URIs in the command-line sequentially
                              and download each URI in a separate session, like
                              the usual command-line download utilities.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic

 -x, --max-connection-per-server=NUM The maximum number of connections to one
                              server for each download.

                              Possible Values: 1-16
                              Default: 1
                              Tags: #basic, #http, #ftp

 -k, --min-split-size=SIZE    aria2 does not split less than 2*SIZE byte range.
                              For example, let's consider downloading 20MiB
                              file. If SIZE is 10M, aria2 can split file into 2
                              range [0-10MiB) and [10MiB-20MiB) and download it
                              using 2 sources(if --split >= 2, of course).
                              If SIZE is 15M, since 2*15M > 20MiB, aria2 does
                              not split file and download it using 1 source.
                              You can append K or M(1K = 1024, 1M = 1024K).

                              Possible Values: 1048576-1073741824
                              Default: 20M
                              Tags: #basic, #http, #ftp

 --ftp-user=USER              Set FTP user. This affects all URLs.

                              Tags: #basic, #ftp

 --ftp-passwd=PASSWD          Set FTP password. This affects all URLs.

                              Tags: #basic, #ftp

 --http-user=USER             Set HTTP user. This affects all URLs.

                              Tags: #basic, #http

 --http-passwd=PASSWD         Set HTTP password. This affects all URLs.

                              Tags: #basic, #http

 --load-cookies=FILE          Load Cookies from FILE using the Firefox3 format
                              and Mozilla/Firefox(1.x/2.x)/Netscape format.

                              Possible Values: /path/to/file
                              Tags: #basic, #http, #cookie

 -S, --show-files[=true|false] Print file listing of .torrent, .meta4 and
                              .metalink file and exit. More detailed
                              information will be listed in case of torrent
                              file.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #metalink, #bittorrent

 --max-overall-upload-limit=SPEED Set max overall upload speed in bytes/sec.
                              0 means unrestricted.
                              You can append K or M(1K = 1024, 1M = 1024K).
                              To limit the upload speed per torrent, use
                              --max-upload-limit option.

                              Possible Values: 0-*
                              Default: 0
                              Tags: #basic, #bittorrent

 -u, --max-upload-limit=SPEED Set max upload speed per each torrent in
                              bytes/sec. 0 means unrestricted.
                              You can append K or M(1K = 1024, 1M = 1024K).
                              To limit the overall upload speed, use
                              --max-overall-upload-limit option.

                              Possible Values: 0-*
                              Default: 0
                              Tags: #basic, #bittorrent

 -T, --torrent-file=TORRENT_FILE  The path to the .torrent file.

                              Possible Values: /path/to/file
                              Tags: #basic, #bittorrent

 --listen-port=PORT...        Set TCP port number for BitTorrent downloads.
                              Multiple ports can be specified by using ',',
                              for example: "6881,6885". You can also use '-'
                              to specify a range: "6881-6999". ',' and '-' can
                              be used together.

                              Possible Values: 1024-65535
                              Default: 6881-6999
                              Tags: #basic, #bittorrent

 --enable-dht[=true|false]    Enable IPv4 DHT functionality. It also enables
                              UDP tracker support. If a private flag is set
                              in a torrent, aria2 doesn't use DHT for that
                              download even if ``true`` is given.

                              Possible Values: true, false
                              Default: true
                              Tags: #basic, #bittorrent

 --dht-listen-port=PORT...    Set UDP listening port used by DHT(IPv4, IPv6)
                              and UDP tracker. Multiple ports can be specified
                              by using ',', for example: "6881,6885". You can
                              also use '-' to specify a range: "6881-6999".
                              ',' and '-' can be used together.

                              Possible Values: 1024-65535
                              Default: 6881-6999
                              Tags: #basic, #bittorrent

 --enable-dht6[=true|false]   Enable IPv6 DHT functionality.
                              Use --dht-listen-port option to specify port
                              number to listen on. See also --dht-listen-addr6
                              option.

                              Possible Values: true, false
                              Default: false
                              Tags: #basic, #bittorrent

 --dht-listen-addr6=ADDR      Specify address to bind socket for IPv6 DHT.
                              It should be a global unicast IPv6 address of the
                              host.

                              Tags: #basic, #bittorrent

 -M, --metalink-file=METALINK_FILE The file path to the .meta4 and .metalink
                              file. Reads input from stdin when '-' is
                              specified.

                              Possible Values: /path/to/file, -
                              Tags: #basic, #metalink

URI, MAGNET, TORRENT_FILE, METALINK_FILE:
 You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z option, all
 URIs must point to the same file or downloading will fail.
 You can also specify arbitrary number of BitTorrent Magnet URIs, torrent/
 metalink files stored in a local drive. Please note that they are always
 treated as a separate download.

 You can specify both torrent file with -T option and URIs. By doing this,
 download a file from both torrent swarm and HTTP/FTP server at the same time,
 while the data from HTTP/FTP are uploaded to the torrent swarm. For single file
 torrents, URI can be a complete URI pointing to the resource or if URI ends
 with '/', 'name' in torrent file is added. For multi-file torrents, 'name' and
 'path' in torrent are added to form a URI for each file.

 Make sure that URI is quoted with single(') or double(") quotation if it
 contains "&" or any characters that have special meaning in shell.

About the number of connections
 Since 1.10.0 release, aria2 uses 1 connection per host by default and has 20MiB
 segment size restriction. So whatever value you specify using -s option, it
 uses 1 connection per host. To make it behave like 1.9.x, use
 --max-connection-per-server=4 --min-split-size=1M.

Refer to man page for more information.

挑几个比较有用的总结一下

-l, --log=LOG 指定日志文件,也可以是路径,指定-的场合日志输出到stdout

-d, --dir=DIR 指定下载目录,默认不指定就是程序运行的目录。

-o, --out=FILE 指定文件名

-s, --split=N 下载一个文件使用的连接数,下载的时候会显示出来(即CN,我猜是connection number),默认是5,如果这个数值大于给的资源地址(URI)数,那么就会有资源地址建立多个连接。如果这个值小于给的资源地址(URI)数,那么多余的URL作为备用地址。

对同一host地址的请求会受到 --max-connection-per-server选项的限制。

--file-allocation=METHOD 文件空间预分配方式,

支持以下几种方式: none, prealloc, trunc, falloc 默认是 prealloc

prealloc会在下载之前分配磁盘空间,花费的时间取决于文件的大小。

如果用的是比较新的文件系统比如ext4,btrfs, xfs or NTFS,最好使用falloc选项,这个方式分配几gb大小的大文件的速度很快。

但是在fat32,和ext3上面建议使用prealloc,因为falloc在这些系统上没有速度优势。

mac系统下这个选项要注释掉。

-c, --continue[=true|false] 可以继续其他下载器的未完成的下载,当然必须是连续的文件,而且只支持http(s)和ftp的下载,默认是false

-i, --input-file=FILE 这个选项是用来从文件中找URI下载的,比如你的txt文件中每行列一个下载地址,然后他就会都下载了。

-j, --max-concurrent-downloads=N 最大下载连接数,默认是5个

-Z, --force-sequential[=true|false] 强制连续性下载,默认是false

-x, --max-connection-per-server=NUM 单服务器的最大连接数,范围在1-16,默认是1

-k, --min-split-size=SIZE

-k, --min-split-size=SIZE 分块大小,aria2c下载的文件大小如果小于两倍的这个值就会选择只从一个地址下载。默认是20M ,你也可以指定K

--load-cookies=FILE 导入cookie文件,需要特殊格式,Firefox3 format and Mozilla/Firefox(1.x/2.x)/Netscape format,这里有chrome插件可以实现。

基础设置就以上这么些

03.配置文件

github上找到一份配置文件相关的项目,有比较多的star,所以就直接拿来作为参考了

由于我是在windows下使用,所以作者提供的一些shell脚本都被我注释掉了,目录也换成了windows下能用的。

注意下面有些目录要换成你自己系统上设置的目录,conf文件默认目录是%USERPROFILE%/.aria2/aria2.conf,需要自己创建,还有aria2.session文件也要事先创建好

#=====================================
# https://github.com/P3TERX/aria2.conf
# File name:aria2.conf
# Description: Aria2 config file
# Lisence: MIT
# Author: P3TERX
# Blog: https://p3terx.com
#=====================================

## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##
## 被注释的选项使用的是默认值, 建议在需要使用时再取消注释  ##

## RPC相关设置 ##

# 启用RPC, 默认:false
enable-rpc=true
# 接受所有远程请求, 默认:false
rpc-allow-origin-all=true
# 允许外部访问, 默认:false
rpc-listen-all=true
# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同
#event-poll=select
# RPC监听端口, 端口被占用时可以修改, 默认:6800
rpc-listen-port=6800
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
# rpc-secret=P3TERX
rpc-secret=mudssky
# 是否启用 RPC 服务的 SSL/TLS 加密,
# 启用加密后 RPC 服务需要使用 https 或者 wss 协议连接
#rpc-secure=true
# 在 RPC 服务中启用 SSL/TLS 加密时的证书文件(.pem/.crt)
#rpc-certificate=/config/xxx.pem
# 在 RPC 服务中启用 SSL/TLS 加密时的私钥文件(.key)
#rpc-private-key=/config/xxx.key

## 文件保存相关 ##

# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
# dir=/root/Download
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
# VPS 默认即可。本地路由器或 NAS 建议在有足够的内存空闲情况下设置为适当的大小,以减少磁盘 I/O 延长硬盘寿命。
#disk-cache=32M
# 文件预分配方式,, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持,falloc 能有效降低磁盘碎片与内存占用
# NTFS(MinGW构建)、EXT4 建议使用 falloc, EXT3 建议 trunc, MAC 下需要注释此项。
# 若无法下载,提示 fallocate failed.cause:Operation not supported ,请设置为 none 
file-allocation=falloc
# 断点续传
continue=true
# 获取服务器文件时间,默认:false
remote-time=true

## 下载连接相关 ##

# 文件未找到重试次数,默认:0
# 重试时同时会记录重试次数,所以也需要设置 --max-tries 这个选项
max-file-not-found=5
# 最大尝试次数,0表示无限,默认:5
max-tries=0
# 重试等待时间(秒), 默认:0
retry-wait=10
# 使用 UTF-8 处理 Content-Disposition ,默认:false
content-disposition-default-utf8=true
# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=5
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=16
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为 15MiB 则使用一个来源下载
min-split-size=4M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=16
# 整体下载速度限制, 运行时可修改, 默认:0
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0
#max-download-limit=0
# 整体上传速度限制, 运行时可修改, 默认:0
max-overall-upload-limit=1M
# 单个任务上传速度限制, 默认:0
#max-upload-limit=1000
# 禁用IPv6, 默认:false
disable-ipv6=true
# 支持GZip,默认:false
http-accept-gzip=true
# URI复用,默认: true
reuse-uri=false
# 禁用 netrc 支持,默认:flase
no-netrc=true

## 进度保存相关 ##

# 从会话文件中读取下载任务
# 注意在windows下,aria2c似乎并不支持这种环境变量,所以这里%USERPROFILE%替换成你的对应目录就行。

# input-file=/root/.aria2/aria2.session
input-file=%USERPROFILE%/.aria2/aria2.session
# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件
# save-session=/root/.aria2/aria2.session
input-file=%USERPROFILE%/.aria2/aria2.session
# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
save-session-interval=1
# 自动保存任务进度,0为退出时才保存,默认:60
auto-save-interval=1
# 强制保存会话, 即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
#force-save=true

## BT/PT下载相关 ##

# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true,可选:false|mem
#follow-torrent=true
# BT监听端口(TCP), 默认:6881-6999
listen-port=51413
# 单个种子最大连接数,0为不限制,默认:55
bt-max-peers=0
# DHT(IPv4)文件
# dht-file-path=%USERPROFILE%/.aria2/dht.dat
dht-file-path=%USERPROFILE%/.aria2/dht.dat
# DHT(IPv6)文件
dht-file-path6=%USERPROFILE%/.aria2/dht6.dat
# 打开DHT功能, PT需要禁用, 默认:true
enable-dht=true
# 打开IPv6 DHT功能, PT需要禁用
# 在没有 IPv6 的环境中不建议开启,否则会导致 DHT 功能异常。
enable-dht6=false
# DHT网络监听端口(UDP), 默认:6881-6999
dht-listen-port=6881-6999
# 本地节点查找, PT需要禁用, 默认:false
bt-enable-lpd=true
# 种子交换, PT需要禁用, 默认:true
enable-peer-exchange=true
# 期望下载速度,Aria2会临时提高连接数以提高下载速度,单位K或M。默认:50K
bt-request-peer-speed-limit=10M
# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0
seed-ratio=1.0
# 最小做种时间(分钟)。此选项设置为0时,将在BT任务下载完成后不进行做种。
seed-time=0
# BT校验相关, 默认:true
#bt-hash-check-seed=true
# 继续之前的BT任务时, 无需再次校验, 默认:false
#bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
bt-save-metadata=true
# 加载已保存的元数据文件,默认:false
bt-load-saved-metadata=true
# 删除未选择文件,默认:false
bt-remove-unselected-file=true
# 保存上传的种子,默认:true
#rpc-save-upload-metadata=false
# 客户端伪装
user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
# PT需要保持 user-agent 和 peer-agent 两个参数一致。即注释上面这行,然后取消注释下面的相关选项。
#user-agent=qBittorrent/4.2.1
peer-agent=qBittorrent/4.2.1
peer-id-prefix=-qB4210-
#----------------------------------
#user-agent=Transmission 2.94
#peer-agent=Transmission 2.94
#peer-id-prefix=-TR2940-
#----------------------------------
#user-agent=Deluge 2.0.3
#peer-agent=Deluge 2.0.3
#peer-id-prefix=-DE2030-
#----------------------------------
#user-agent=μTorrent 3.5.5
#peer-agent=μTorrent 3.5.5
#peer-id-prefix=-UT355W-
#----------------------------------
#user-agent=μTorrent Mac 1.8.7
#peer-agent=μTorrent Mac 1.8.7
#peer-id-prefix=-UM1870-

## BT加密设置(抗版权、防吸血) ##

# BT强制加密, 默认: false
# 启用后将拒绝旧的 BT 握手协议并仅使用混淆握手及加密,理论上可以防版权投诉与迅雷吸血。
# 此选项相当于后面两个选项(bt-require-crypto=true, bt-min-crypto-level=arc4)的快捷开启方式,但不会修改这两个选项的值。
bt-force-encryption=true
# BT加密需求,默认:false
# 启用后拒绝与旧的BitTorrent握手协议(\19BitTorrent protocol)建立连接,始终使用混淆处理握手。
#bt-require-crypto=true
# BT最低加密等级,可选:plain(明文),arc4(加密),默认:plain
#bt-min-crypto-level=arc4

## 执行额外命令 ##

# 下载停止后执行的命令(下载停止包含下载错误和下载完成这两个状态,如果没有单独设置,则执行此项命令。)
# 删除文件及.aria2后缀名文件
# on-download-stop=/root/.aria2/delete.sh
# 下载错误后执行的命令(下载停止包含下载错误这个状态,如果没被设置或被注释,则执行下载停止后执行的命令。)
#on-download-error=
# 下载完成后执行的命令(下载停止包含下载完成这个状态,如果没被设置或被注释,则执行下载停止后执行的命令。)
# 删除.aria2后缀名文件
# on-download-complete=/root/.aria2/delete.aria2.sh
# 调用 rclone 上传(move)到网盘
#on-download-complete=/root/.aria2/autoupload.sh
# 下载暂停后执行的命令
# 显示下载任务信息
#on-download-pause=/root/.aria2/info.sh
# 下载开始后执行的命令
#on-download-start=

## BT服务器 ##
bt-tracker=

aria2c 默认 导入配置文件的路径就是%USERPROFILE%/.aria2/aria2.session,把文件放到这里就可以了。

也可以使用--conf-path=PATH来指定别的路径,也可以用--no-conf[=true|false]选择不导入配置文件的配置。

然后关于windows下falloc执行失败的问题,因为会提示需要管理员权限。

具体会出现类似以下的错误

02/29 11:01:06 [WARN] Gaining privilege SeManageVolumePrivilege failed.

02/29 11:01:06 [WARN] --file-allocation=falloc will not work properly.

02/29 11:01:06 [WARN] File allocation (SetFileValidData) failed (cause: A required privilege is not held by the client.). File will be allocated by filling zero, which blocks whole aria2 execution. Run aria2 as an administrator or use a different file allocation method (see --file-allocation).

其实这个预分配的作用是预先分配一块连续的空间,可以有效减少磁盘碎片,也就是一个保护磁盘延长寿命的作用。

迅雷以前的下载刚开始的几分钟都是在预分配,估计就是prealloc方式,要花相当一段时间。

windows下powershell提升权限的方法比较有限,似乎只能新打开一个管理员权限的powershell,也可以用来以管理员权限运行一个进程,但是youtube-dl调用的时候不会自动给你用管理员权限运行。所以说目前我的使用场景比较合适的方式就是在管理员权限的powershell下运行

执行下面的命令就可以在管理员权限下打开一个powershell窗口

Start-Process powershell -Verb runAs

还是比较麻烦,我的使用场景不如直接考虑在右键打开管理员权限的终端。我使用的终端时windows terminal。它目前并不支持切换管理员模式的终端。相在windows terminal下打开管理员模式的powershell,只有先打开管理员模式的windows terminal,然后打开的powershell和cmd就都是管理员模式的。

github上有一个issue还在讨论,但是到现在还没有结果。所以等这个功能实装估计要好久,甚至就不会实装。

https://github.com/microsoft/terminal/issues/632

管理员模式的使用情况也比较有限,所以我这里不如就使用prealloc方式算了,反正下载的文件也不会太大,花不了太多时间。

你可能感兴趣的:(win10 aria2c下载器的简单使用指南,配置文件)