Does aria2 Support Netscape cookies.txt Files?
The command-line download utility aria2 natively
supports reading HTTP cookies from files formatted in the standard
Netscape/Mozilla cookies.txt layout. This capability allows
users to seamlessly pass session data and authentication states from web
browsers directly into their command-line download workflows. By
utilizing specific command-line flags, aria2 can parse
these files to download files from servers that require active
authentication or specific session states.
How aria2 Handles Netscape Cookies
When downloading files from websites that require a login, standard
URLs are often insufficient because the server expects authentication
tokens stored in the browser’s cookies. aria2 resolves this
by accepting an external cookie file.
The Netscape cookie format is a widely accepted, tab-delimited text format where each line represents a single cookie with seven distinct fields:
- Domain: The domain that created and can read the cookie.
- Flag: A TRUE/FALSE value indicating if all machines within the domain can access the cookie.
- Path: The web path on the server for which the cookie is valid.
- Secure: A TRUE/FALSE value indicating if a secure HTTPS connection is required.
- Expiration: The UNIX timestamp dictating when the cookie expires.
- Name: The name of the cookie variable.
- Value: The data stored within the cookie.
Because browsers like Firefox and Chrome (via extensions) can easily
export active sessions into this exact seven-column format,
aria2 can read these files directly without requiring any
prior conversion or reformatting.
Using the –load-cookies Option
To instruct aria2 to read a Netscape-formatted cookie
file, you must use the --load-cookies option during
execution.
The basic command syntax is structured as follows:
aria2c --load-cookies=cookies.txt "https://example.com/file.zip"In this command, aria2c initiates the program,
--load-cookies=cookies.txt points to the path of your
exported Netscape cookie file, and the final argument is the target
URL.
Key Behaviors to Note
- Session Modification: By default,
aria2only reads the cookies to authenticate the current download session. If the server attempts to update or send new cookies during the download,aria2will process them in memory but will not alter your originalcookies.txtfile. - Saving Updated Cookies: If you need
aria2to save any newly received or updated cookies back to a file for future use, you must pair the load command with the save command:
aria2c --load-cookies=cookies.txt --save-cookies=updated_cookies.txt "https://example.com/file.zip"Using these options ensures that complex download tasks requiring persistent authentication states can be handled efficiently directly through the command line.