简体   繁体   English

自动重试 aria2c 下载以在脚本中使用

[英]Automatically Retry aria2c download for using in a script

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:我正在编写一个python脚本,我在其中抓取下载链接,然后使用aria2下载器“ aria2c.exe一一下载,如下所示:

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 .如您所见,如果任何一次下载失败,“ aria2c -x 5 ... -o ... ”过程就会结束,下一个“ downloadLink ”开始被aria2下载。

What I want is that aria2c automatically retries if there is failure.我想要的是,如果出现故障,aria2c 会自动重试。 I want it to behave like Internet Download Manager (IDMan).我希望它表现得像 Internet 下载管理器 (IDMan)。 IDMan downloads it way better than aria2 (high speed and retry automatic). IDMan 下载方式比 aria2 好(高速和自动重试)。

So please also give me the best command options I should use with aria2 because I want the download fast and reliable!所以还请给我最好的命令选项,我应该与aria2 一起使用,因为我希望下载快速可靠!

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.首先,您可以使用--input-file选项并同时传递所有链接,这样 aria2 可以根据需要并行下载多个文件。

Then use --save-session option to save the list of files which failed to download.然后使用--save-session选项保存下载失败的文件列表。 If the session file is not empty, there are failures.如果会话文件不为空,则表示失败。 Restart aria2 with the saved session as input.使用保存的会话作为输入重新启动 aria2。

You can also use --continue option to stop aria2 from downloading an existing file once again.您还可以使用--continue选项阻止 aria2 再次下载现有文件。

See Any way to keep only list of failed downloads?请参阅任何方法只保留失败下载的列表? question for a sample script which basically does what you want.一个示例脚本的问题,它基本上可以满足您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM