下载视频时由对等错误重置连接

时间:2015-02-22 00:26:16

标签: shell download sh youtube-dl

我编写了一个shell脚本来下载视频并执行一些操作。我使用的是youtube-dl,因为我有一个网页网址,需要从该网页下载视频。脚本是

#!/bin/bash
cd /media/user/path/home/user/Videos/X
youtube-dl http://someUrl.com/somePath
#Do other operations

视频开始下载,并在一段时间后显示ERROR: unable to download video data: [Errno 104] Connection reset by peer

我尝试从Ubuntu终端运行此命令。当我重新运行相同的命令时,视频下载会在几秒钟/几分钟后重新开始并再次停止。有没有什么方法可以在下载视频之前自动重新运行相同的命令?如何捕获此错误并以递归方式运行youtube-dl命令?

作为参考我在终端运行了命令,显示了下面的终端输出:

user@user-ThinkPad-T430:/media/user/path/home/user/Videos/X$ youtube-dl http://someUrl.com/somePath
[generic] somePath: Requesting header
WARNING: Falling back on generic information extractor.
[generic] somePath: Downloading webpage
[generic] somePath: Extracting information
[download] Resuming download at byte 79260669
[download] Destination:   someVideo - someUrl.-somePath.mp4
[download]  42.2% of 185.01MiB at 18.13KiB/s ETA 01:40:45ERROR: unable to download video data: [Errno 104] Connection reset by peer
user@user-ThinkPad-T430:/media/user/path/home/user/Videos/X$ youtube-dl http://someUrl.com/somePath
[generic] somePath: Requesting header
WARNING: Falling back on generic information extractor.
[generic] somePath: Downloading webpage
[generic] somePath: Extracting information
[download] Resuming download at byte 81777461
[download] Destination:   someVideo - someUrl.-somePath.mp4
[download]  44.3% of 185.01MiB at 21.68KiB/s ETA 01:21:12ERROR: unable to download video data: [Errno 104] Connection reset by peer

还告诉我是否还有其他替代方式。

0 个答案:

没有答案