0

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!

Ali Sajjad
  • 3,589
  • 1
  • 28
  • 38

1 Answers1

0

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.

Alexey Ivanov
  • 11,541
  • 4
  • 39
  • 68
  • I followed your suggestion and executed this `aria2c -j 10 --https-proxy=http://localhost:9080 -i links1.txt --save-session links2.txt` but despite most of the links in the input file were downloaded successfully, the content of links2.txt is identical to links1.txt? And when I then execute `aria2c -j 10 --https-proxy=http://localhost:9080 -i links2.txt --save-session links3.txt` the same files are downloaded again. (And links3.txt is identical to links1.txt and links2.txt). I just want to redownload the failed downloads. How do I do that? – d-b Jul 26 '23 at 22:50
  • The summary after the download looks like this: `(ERR):error occurred. aria2 will resume download if the transfer is restarted. If there are any errors, then see the log file. See '-l' option in help/man page for details. 07/26 22:35:35 [NOTICE] Serialized session to 'links2.txt' successfully.` – d-b Jul 26 '23 at 22:52
  • @d-b It works for me as expected, only the failed downloads are written into the session file. However, I tested it with a file that doesn't exist on the server. With `--continue` option, `aria2c` didn't download the completed files again when I ran it with the same input file. – Alexey Ivanov Aug 11 '23 at 15:43