aria2 provides options to specify arbitrary command after specific event occurred. Currently following options are available: --on-bt-download-complete, --on-download-pause, --on-download-complete. --on-download-start, --on-download-error, --on-download-stop.
aria2 passes 3 arguments to specified command when it is executed. These arguments are: GID, the number of files and file path. For HTTP, FTP, and SFTP downloads, usually the number of files is 1. BitTorrent download can contain multiple files. If number of files is more than one, file path is first one. In other words, this is the value of path key of first struct whose selected key is true in the response of aria2.getFiles() RPC method. If you want to get all file paths, consider to use JSON-RPC/XML-RPC. Please note that file path may change during download in HTTP because of redirection or Content-Disposition header.