Automatically Retry aria2c download for using in a script

3.2k Views Asked by At

I am working on a python script, in which I webscrape download links, and then download them one by one using aria2 downloader 'aria2c.exe' like this:

import os
#...
for downloadLink in someList:
     os.system("aria2c -x 5 " + downloadLink + " -o " + filename + ".mp4")
#...

As you can see, if any one download fails, the process "aria2c -x 5 ... -o ..." ends and the next 'downloadLink' starts to get downloaded by aria2.

What I want is that aria2c automatically retries if there is failure. I want it to behave like Internet Download Manager (IDMan). IDMan downloads it way better than aria2 (high speed and retry automatic).

So please also give me the best command options I should use with aria2 because I want the download fast and reliable!

1

There are 1 best solutions below

3
On

First of all, you can use --input-file option and pass all the links at the same time, this way aria2 will be able to download several files in parallel if you want it to.

Then use --save-session option to save the list of files which failed to download. If the session file is not empty, there are failures. Restart aria2 with the saved session as input.

You can also use --continue option to stop aria2 from downloading an existing file once again.

See Any way to keep only list of failed downloads? question for a sample script which basically does what you want.